public class BinaryHeapQueue extends Object implements Queue, Externalizable
| Modifier and Type | Class and Description |
|---|---|
static class |
BinaryHeapQueue.Synchronized |
| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
log |
| Constructor and Description |
|---|
BinaryHeapQueue() |
BinaryHeapQueue(Comparator<Activation> comparator)
Constructs a new
BinaryHeap that will use the given
comparator to order its elements. |
BinaryHeapQueue(Comparator<Activation> comparator,
int capacity)
Constructs a new
BinaryHeap. |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears all elements from queue.
|
Activation |
dequeue()
Returns the Queueable on top of heap and remove it.
|
Activation |
dequeue(Activation activation) |
void |
enqueue(Activation element)
Inserts an Queueable into queue.
|
Activation[] |
getAndClear() |
boolean |
isEmpty()
Tests if queue is empty.
|
boolean |
isFull()
Tests if queue is full.
|
Activation |
peek() |
protected void |
percolateDownMaxHeap(int index)
Percolates element down heap from the position given by the index.
|
protected void |
percolateUpMaxHeap(Activation element)
Percolates a new element up heap from the bottom.
|
protected void |
percolateUpMaxHeap(int index)
Percolates element up heap from from the position given by the index.
|
void |
readExternal(ObjectInput in) |
int |
size()
Returns the number of elements in this heap.
|
Object[] |
toArray(Object[] a) |
String |
toString() |
void |
writeExternal(ObjectOutput out) |
public BinaryHeapQueue()
public BinaryHeapQueue(Comparator<Activation> 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<Activation> comparator, int capacity)
BinaryHeap.comparator - the comparator used to order the elements, null
means use natural ordercapacity - the initial capacity for the heapIllegalArgumentException - if capacity is <= 0public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionpublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void clear()
public Activation[] getAndClear()
public boolean isEmpty()
public boolean isFull()
true if queue is full; false
otherwise.public int size()
public Activation peek()
public void enqueue(Activation element)
public Activation dequeue()
dequeue in interface QueueNoSuchElementException - if isEmpty() == truepublic Activation dequeue(Activation activation)
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(Activation element)
Assume it is a maximum heap.
element - the elementCopyright © 2001–2019 JBoss by Red Hat. All rights reserved.