Interface PriorityQueue<E>

Type Parameters:
E - Type of elements in Priority Queue
All Superinterfaces:
Iterable<E>, Queue<E>

public interface PriorityQueue<E> extends Queue<E>
Priority queue used by the Heap sorter.
Author:
Richard van den Ham (r.vandenham@fontys.nl)
  • Method Details

    • get

      E get()
      Remove SMALLEST element of the queue and return it. The ordering is based on the Comparator<E> provided to the constructor.
      Specified by:
      get in interface Queue<E>
      Returns:
      the SMALLEST element in this queue, or null if queue is empty.
    • getComparator

      Comparator<E> getComparator()
      Get the comparator used to compare elements.
      Returns:
      comparator
    • iterator

      Iterator<E> iterator()
      Iterator to iterate over Priority queue. Hint to implementer: we expect the implementation to CONSUME the priority queue. This means that the hasNext() method checks if the priority queue is not empty and the next() method invokes the get() method. As a result, the iterator will return elements in sorted order and after using the iterator, the priority queue will be empty.
      Specified by:
      iterator in interface Iterable<E>
      Returns:
      iterator