|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.placelab.util.DHeap
| Field Summary | |
protected java.util.Comparator |
comparator
|
protected java.lang.Object[] |
data
|
| Constructor Summary | |
DHeap(java.util.Comparator c,
int dSize)
Default Constructor. |
|
DHeap(java.util.Comparator c,
int dSize,
int capacity)
Other Constructor. |
|
| Method Summary | |
java.lang.Object |
deleteMin()
Returns and removes the smallest object in the heap. |
java.lang.Object |
findMin()
Find the smallest item in the heap. |
void |
insert(java.lang.Object x)
Inserts a new object to the priority queue |
boolean |
isEmpty()
Returns true if priority queue has no elements |
static void |
main(java.lang.String[] args)
|
void |
makeEmpty()
Makes the heap empty by replacing the old data array with a new empty one of size initialSize. |
protected void |
percolateDown(int startNode)
Method to percolate down from a given node in the heap. |
protected void |
percolateUp(int startNode)
Method to percolate up from a given node in the heap. |
boolean |
remove(java.lang.Object o)
Removes the requested element from the queue, if it exists. |
int |
size()
Finds the size of the heap |
java.lang.String |
toString()
Returns a level-order traversal of the heap |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.lang.Object[] data
protected java.util.Comparator comparator
| Constructor Detail |
public DHeap(java.util.Comparator c,
int dSize)
c - an instance of the comparator to use for ordering the heapdSize - the number of children a node can have (>=2)
public DHeap(java.util.Comparator c,
int dSize,
int capacity)
c - an instance of the comparator to use for ordering the heapdSize - the number of children a node can have (>=2)capacity - the initial size of the heap (>=1)| Method Detail |
public int size()
public boolean remove(java.lang.Object o)
true if element found and removed
false otherwise.public boolean isEmpty()
PriorityQueue
isEmpty in interface PriorityQueuepublic java.lang.Object findMin()
findMin in interface PriorityQueueEmptyHeapException - if heap is emptypublic void insert(java.lang.Object x)
PriorityQueue
insert in interface PriorityQueuex - Object to be inserted into the priority queue.public java.lang.Object deleteMin()
deleteMin in interface PriorityQueueEmptyHeapException - if the heap is emptypublic void makeEmpty()
makeEmpty in interface PriorityQueueprotected void percolateUp(int startNode)
startNode - the index of the node at which the percolate begins.protected void percolateDown(int startNode)
startNode - the index of the node at which the percolate begins.public java.lang.String toString()
public static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||