|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.drools.core.util.BinaryHeapQueue
public class BinaryHeapQueue
Constructor Summary | |
---|---|
BinaryHeapQueue()
|
|
BinaryHeapQueue(Comparator comparator)
Constructs a new BinaryHeap that will use the given
comparator to order its elements. |
|
BinaryHeapQueue(Comparator comparator,
int capacity)
Constructs a new BinaryHeap . |
Method Summary | |
---|---|
void |
clear()
Clears all elements from queue. |
Queueable |
dequeue()
Returns the Queueable on top of heap and remove it. |
Queueable |
dequeue(int index)
|
void |
enqueue(Queueable element)
Inserts an Queueable into queue. |
Activation[] |
getAndClear()
|
boolean |
isEmpty()
Tests if queue is empty. |
boolean |
isFull()
Tests if queue is full. |
protected void |
percolateDownMaxHeap(int index)
Percolates element down heap from the position given by the index. |
protected void |
percolateUpMaxHeap(int index)
Percolates element up heap from from the position given by the index. |
protected void |
percolateUpMaxHeap(Queueable element)
Percolates a new element up heap from the bottom. |
void |
readExternal(ObjectInput in)
|
int |
size()
Returns the number of elements in this heap. |
Object[] |
toArray(Object[] a)
|
void |
writeExternal(ObjectOutput out)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BinaryHeapQueue()
public BinaryHeapQueue(Comparator comparator)
BinaryHeap
that will use the given
comparator to order its elements.
comparator
- the comparator used to order the elements, null
means use natural orderpublic BinaryHeapQueue(Comparator comparator, int capacity)
BinaryHeap
.
comparator
- the comparator used to order the elements, null
means use natural ordercapacity
- the initial capacity for the heap
IllegalArgumentException
- if capacity
is <= 0
Method Detail |
---|
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void clear()
public Activation[] getAndClear()
public boolean isEmpty()
isEmpty
in interface Queue
true
if queue is empty; false
otherwise.public boolean isFull()
true
if queue is full; false
otherwise.public int size()
public void enqueue(Queueable element)
enqueue
in interface Queue
element
- the Queueable to be insertedpublic Queueable dequeue() throws NoSuchElementException
dequeue
in interface Queue
NoSuchElementException
- if isEmpty() == true
public Queueable dequeue(int index)
dequeue
in interface Queue
index
- protected void percolateDownMaxHeap(int index)
Assumes it is a maximum heap.
index
- the index of the elementprotected void percolateUpMaxHeap(int index)
Assume it is a maximum heap.
index
- the index of the element to be percolated upprotected void percolateUpMaxHeap(Queueable element)
Assume it is a maximum heap.
element
- the elementpublic Object[] toArray(Object[] a)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |