Package smile.util

Class PriorityQueue

java.lang.Object
smile.util.PriorityQueue

public class PriorityQueue extends Object
Priority Queue for index items.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PriorityQueue(double[] a)
    Constructor.
    PriorityQueue(int d, double[] a)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    change(int k)
    The priority of item k has changed.
    void
    insert(int v)
    Insert a new item into queue.
    boolean
    Returns true if the queue is empty.
    void
    lower(int k)
    The value of item k is lower (higher priority) now.
    int
    Removes and returns the index of item with minimum value (highest priority).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PriorityQueue

      public PriorityQueue(double[] a)
      Constructor. Default use a 3-heap.
      Parameters:
      a - external array of priority. Lower value means higher priority.
    • PriorityQueue

      public PriorityQueue(int d, double[] a)
      Constructor.
      Parameters:
      d - d-heap.
      a - external array of priority. Lower value means higher priority.
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Returns true if the queue is empty.
      Returns:
      true if the queue is empty.
    • insert

      public void insert(int v)
      Insert a new item into queue.
      Parameters:
      v - the index of item.
    • poll

      public int poll()
      Removes and returns the index of item with minimum value (highest priority).
      Returns:
      the index of item with minimum value.
    • lower

      public void lower(int k)
      The value of item k is lower (higher priority) now.
      Parameters:
      k - the item index.
    • change

      public void change(int k)
      The priority of item k has changed.
      Parameters:
      k - the item index.