Interface CustomCollection<E>

All Superinterfaces:
Iterable<E>
All Known Implementing Classes:
FIFOQueue, LIFOQueue, PRIOQueue

public interface CustomCollection<E> extends Iterable<E>
Interface that simulates the beheviour of the Collection interface in Java. This interface acts as a supertype for all the types of queue used in the station, like FIFO, LIFO, Priority
Author:
Lorenzo Torri Date: 25-mar-2024 Time: 13.10
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Add a new element to the Collection, how to add and where to add it, it will be handled by the classes that implements this interface
    Retrieve the first element of the Collection
    This is the method of the Iterable<E> interface, needed for iterating over the Collection
    boolean
    Remove the head of the Collection
    boolean
    Remove the Object o from the list.
    int
    Get the size of the Collection

    Methods inherited from interface Iterable

    forEach, spliterator
  • Method Details

    • addNew

      boolean addNew(Object o)
      Add a new element to the Collection, how to add and where to add it, it will be handled by the classes that implements this interface
      Parameters:
      o - Object to add
      Returns:
      true if the adding was successful
    • removeHead

      boolean removeHead()
      Remove the head of the Collection
      Returns:
      true if the head is removed correctly
    • first

      Object first()
      Retrieve the first element of the Collection
      Returns:
      the first element of the Collection, null otherwise
    • iterator

      Iterator<E> iterator()
      This is the method of the Iterable<E> interface, needed for iterating over the Collection
      Specified by:
      iterator in interface Iterable<E>
    • size

      int size()
      Get the size of the Collection
      Returns:
      size of the collection
    • removeObject

      boolean removeObject(Object o)
      Remove the Object o from the list. Used for specific cases like BoxStation in PS that has to remove the job from the queue
      Parameters:
      o - the object
      Returns:
      true if it has removed the object correctly