Package edu.uky.ai.path

# Class PriorityQueue<T>

java.lang.Object
edu.uky.ai.path.PriorityQueue<T>

Type Parameters:
  `T` - the type of object to be stored in the queue

All Implemented Interfaces:
  `java.lang.Iterable<T>`

    public class PriorityQueue<T>
    extends java.lang.Object
    implements java.lang.Iterable<T>

A priority queue is a collection of things which, after being put in (or "pushed") can be taken out ("popped) in the order defined by the numeric key associated with each thing. This is a min priority queue, meaning that the thing with the smallest key will always be removed next.

Author:
  Stephen G. Ware

- ## Constructor Summary

  Constructors
  Constructor | Description
  --- | ---
  `PriorityQueue()` | Creates a new min priority queue.

- ## Method Summary

  Modifier and Type | Method | Description
  --- | --- | ---
  `boolean` | `contains​(java.lang.Object object)` | Tests whether or not a given object is stored in the queue.
  `void` | `forEach​(java.util.function.Consumer<? super T> consumer)` |
  `java.util.Iterator<T>` | `iterator()` |
  `T` | `peek()` | Returns the next object to be removed from the queue.
  `T` | `pop()` | Removes the object with the lowest key from the queue and returns it.
  `void` | `push​(T element, double key)` | Adds an object to the queue and associates the object with a numeric key that will be used to determine in what order the object comes out.
  `int` | `size()` | Returns the number of elements current stored in the queue.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface java.lang.Iterable

  `spliterator`

- ## Constructor Details

  - ### PriorityQueue

    public PriorityQueue()
    Creates a new min priority queue.

- ## Method Details

  - ### iterator

    public java.util.Iterator<T> iterator()
    Specified by:
      `iterator` in interface `java.lang.Iterable<T>`

  - ### forEach

    public void forEach​(java.util.function.Consumer<? super T> consumer)
    Specified by:
      `forEach` in interface `java.lang.Iterable<T>`

  - ### size

    public int size()
    Returns the number of elements current stored in the queue.
    Returns:
      the number of elements

  - ### contains

    public boolean contains​(java.lang.Object object)
    Tests whether or not a given object is stored in the queue.
    Parameters:
      `object` - the object to test
    Returns:
      true if the object is in the queue, false otherwise

  - ### peek

    public T peek()
    Returns the next object to be removed from the queue.
    Returns:
      the next (minimum) object, or null if the queue is empty

  - ### push

    public void push​(T element, double key)
    Adds an object to the queue and associates the object with a numeric key that will be used to determine in what order the object comes out.
    Parameters:
      `element` - the object to add
      `key` - the numeric key associated with the object

  - ### pop

    public T pop()
    Removes the object with the lowest key from the queue and returns it.
    Returns:
      the object with the lowest key