Class PRIOQueue<E>

All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, List, RandomAccess, SequencedCollection, CustomCollection

public class PRIOQueue<E> extends ArrayList implements CustomCollection
ArrayList that implements the CustomCollection interface, to act as a Priority Queue. This queue needs a Comparator when instantiated, so all the queues that are not LIFO or FIFO can be implemented with this class.
Author:
Lorenzo Torri Date: 25-mar-2024 Time: 13.20
See Also:
  • Constructor Details

    • PRIOQueue

      public PRIOQueue(Comparator<? super E> comp)
  • Method Details

    • addNew

      public boolean addNew(Object o)
      Description copied from interface: CustomCollection
      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
      Specified by:
      addNew in interface CustomCollection<E>
      Parameters:
      o - Object to add
      Returns:
      true if the adding was successful
    • removeHead

      public boolean removeHead()
      Description copied from interface: CustomCollection
      Remove the head of the Collection
      Specified by:
      removeHead in interface CustomCollection<E>
      Returns:
      true if the head is removed correctly
    • first

      public Object first()
      Description copied from interface: CustomCollection
      Retrieve the first element of the Collection
      Specified by:
      first in interface CustomCollection<E>
      Returns:
      the first element of the Collection, null otherwise
    • removeObject

      public boolean removeObject(Object e)
      Description copied from interface: CustomCollection
      Remove the Object o from the list. Used for specific cases like BoxStation in PS that has to remove the job from the queue
      Specified by:
      removeObject in interface CustomCollection<E>
      Parameters:
      e - the object
      Returns:
      true if it has removed the object correctly