|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.avalon.excalibur.collections.BinaryHeap
BinaryHeap implementation of priority queue. The heap is either a minimum or maximum heap as determined by parameters passed to constructor.
Field Summary | |
static Comparator |
MAX_COMPARATOR
Deprecated. Comparator used to instantiate a max heap - assumes contents implement the Comparable interface. |
static Comparator |
MIN_COMPARATOR
Deprecated. Comparator used to instantiate a min heap - assumes contents implement the Comparable interface. |
Constructor Summary | |
BinaryHeap()
Deprecated. Instantiates a new min binary heap with the default initial capacity. |
|
BinaryHeap(boolean isMinHeap)
Deprecated. Create a binary heap of Comparables. |
|
BinaryHeap(Comparator comparator)
Deprecated. Instantiates a new binary heap with the default initial capacity and ordered using the given Comparator. |
|
BinaryHeap(int capacity)
Deprecated. Instantiates a new min binary heap with the given initial capacity. |
|
BinaryHeap(int capacity,
boolean isMinHeap)
Deprecated. Create a binary heap of Comparables. |
|
BinaryHeap(int capacity,
Comparator comparator)
Deprecated. Instantiates a new binary heap with the given initial capacity and ordered using the given Comparator. |
Method Summary | |
void |
clear()
Deprecated. Clear all elements from queue. |
void |
insert(Object element)
Deprecated. Insert an element into queue. |
boolean |
isEmpty()
Deprecated. Test if queue is empty. |
boolean |
isFull()
Deprecated. Test if queue is full. |
Object |
peek()
Deprecated. Return element on top of heap but don't remove it. |
Object |
pop()
Deprecated. Return element on top of heap and remove it. |
int |
size()
Deprecated. Returns the number of elements currently on the heap. |
String |
toString()
Deprecated. Create a string representing heap and all elements in heap. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final Comparator MIN_COMPARATOR
public static final Comparator MAX_COMPARATOR
Constructor Detail |
public BinaryHeap()
public BinaryHeap(int capacity)
capacity
- the size of the heappublic BinaryHeap(Comparator comparator)
comparator
- to order the contents of the heappublic BinaryHeap(int capacity, Comparator comparator)
capacity
- the size of the heapcomparator
- to order the contents of the heappublic BinaryHeap(boolean isMinHeap)
isMinHeap
- true to make it a minimum heap, false to make it a max heappublic BinaryHeap(int capacity, boolean isMinHeap)
capacity
- the size of the heapisMinHeap
- true to make it a minimum heap, false to make it a max heapMethod Detail |
public void clear()
clear
in interface PriorityQueue
public boolean isEmpty()
isEmpty
in interface PriorityQueue
public boolean isFull()
public int size()
public void insert(Object element)
insert
in interface PriorityQueue
element
- the element to be insertedpublic Object peek() throws NoSuchElementException
peek
in interface PriorityQueue
NoSuchElementException
- if isEmpty() == truepublic Object pop() throws NoSuchElementException
pop
in interface PriorityQueue
NoSuchElementException
- if isEmpty() == truepublic String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |