Interface PriorityQueue.Access<E>

Type Parameters:
E - the type of elements held in this queue
Enclosing class:
PriorityQueue<E>

public static interface PriorityQueue.Access<E>
This allows us to store the index into the element itself to improve the performance of inserting or removing elements. Without this mechanism, it will iterate through the queue to find the index.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Retrieves the index previously stored into the element.
    void
    setIndex(E e, int index)
    Stores the new index into the element.
  • Method Details

    • setIndex

      void setIndex(E e, int index)
      Stores the new index into the element. An index of -1 means the element is removed from the queue.
      Parameters:
      e - an element of the queue
      index - the new index of the element in the queue, or -1
    • getIndex

      int getIndex(E e)
      Retrieves the index previously stored into the element. An index of -1 means the element is removed from the queue.
      Parameters:
      e - an element of the queue
      Returns:
      the index of the element in the queue, or -1