Interface PriorityQueue<K,V>

Type Parameters:
K - The key type (keys must be unique and comparable)
V - The value type stored with each entry
All Known Subinterfaces:
AdaptablePriorityQueue<K,V>
All Known Implementing Classes:
AbstractPriorityQueue, HeapAdaptablePriorityQueue, HeapPriorityQueue, SortedPriorityQueue, UnsortedPriorityQueue

public interface PriorityQueue<K,V>
Interface for the priority queue ADT.
  • Method Summary

    Modifier and Type
    Method
    Description
    insert(K key, V value)
    Inserts a key-value pair and returns the entry created.
    boolean
    Tests whether the priority queue is empty.
    min()
    Returns (but does not remove) an entry with minimal key.
    Removes and returns an entry with minimal key.
    int
    Returns the number of items in the priority queue.
  • Method Details

    • size

      int size()
      Returns the number of items in the priority queue.
      Returns:
      number of items
    • isEmpty

      boolean isEmpty()
      Tests whether the priority queue is empty.
      Returns:
      true if the priority queue is empty, false otherwise
    • insert

      Entry<K,V> insert(K key, V value)
      Inserts a key-value pair and returns the entry created.
      Parameters:
      key - the key of the new entry
      value - the associated value of the new entry
      Returns:
      the entry storing the new key-value pair
    • min

      Entry<K,V> min()
      Returns (but does not remove) an entry with minimal key.
      Returns:
      entry having a minimal key (or null if empty)
    • removeMin

      Entry<K,V> removeMin()
      Removes and returns an entry with minimal key.
      Returns:
      the removed entry (or null if empty)