smile.sort
Class PriorityQueue
- java.lang.Object
-
- smile.sort.PriorityQueue
-
public class PriorityQueue extends java.lang.ObjectPriority Queue for index items.
-
-
Constructor Summary
Constructors Constructor and Description PriorityQueue(double[] a)Constructor.PriorityQueue(int d, double[] a)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidchange(int k)The priority of item k has changed.booleanempty()Returns true if the queue is empty.voidinsert(int v)Insert a new item into queue.voidlower(int k)The value of item k is lower (higher priority) now.intpoll()Removes and returns the index of item with minimum value (highest priority).
-
-
-
Constructor Detail
-
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 Detail
-
empty
public boolean 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).
-
lower
public void lower(int k)
The value of item k is lower (higher priority) now.
-
change
public void change(int k)
The priority of item k has changed.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG