|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.avalon.excalibur.collections.BinaryHeap
Iterface for priority queues. This interface does not dictate whether it is min or max heap.
Field Summary | |
protected static int |
DEFAULT_CAPACITY
|
protected java.lang.Comparable[] |
m_elements
|
protected boolean |
m_isMinHeap
|
protected int |
m_size
|
Constructor Summary | |
BinaryHeap()
|
|
BinaryHeap(boolean isMinHeap)
|
|
BinaryHeap(int capacity)
|
|
BinaryHeap(int capacity,
boolean isMinHeap)
|
Method Summary | |
void |
clear()
Clear all elements from queue. |
protected void |
grow()
|
void |
insert(java.lang.Comparable element)
Insert an element into queue. |
boolean |
isEmpty()
Test if queue is empty. |
boolean |
isFull()
Test if queue is full. |
java.lang.Comparable |
peek()
Return element on top of heap but don't remove it. |
protected void |
percolateDownMaxHeap(int index)
Percolate element down heap from top. |
protected void |
percolateDownMinHeap(int index)
Percolate element down heap from top. |
protected void |
percolateUpMaxHeap(java.lang.Comparable element)
Percolate element up heap from bottom. |
protected void |
percolateUpMinHeap(java.lang.Comparable element)
Percolate element up heap from bottom. |
java.lang.Comparable |
pop()
Return element on top of heap and remove it. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static final int DEFAULT_CAPACITY
protected int m_size
protected java.lang.Comparable[] m_elements
protected boolean m_isMinHeap
Constructor Detail |
public BinaryHeap()
public BinaryHeap(int capacity)
public BinaryHeap(boolean isMinHeap)
public BinaryHeap(int capacity, boolean isMinHeap)
Method Detail |
public void clear()
clear
in interface PriorityQueue
public boolean isEmpty()
isEmpty
in interface PriorityQueue
public boolean isFull()
public void insert(java.lang.Comparable element)
insert
in interface PriorityQueue
element
- the element to be insertedpublic java.lang.Comparable peek() throws java.util.NoSuchElementException
peek
in interface PriorityQueue
java.util.NoSuchElementException
- if isEmpty() == truepublic java.lang.Comparable pop() throws java.util.NoSuchElementException
pop
in interface PriorityQueue
java.util.NoSuchElementException
- if isEmpty() == trueprotected void percolateDownMinHeap(int index)
element
- the elementprotected void percolateDownMaxHeap(int index)
element
- the elementprotected void percolateUpMinHeap(java.lang.Comparable element)
element
- the elementprotected void percolateUpMaxHeap(java.lang.Comparable element)
element
- the elementprotected void grow()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |