|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--u6.Heap | +--u6.ArrayHeap
Array based implementation of Heap Data Structure. The nodes of binary tree of the heap are stored in a lenear structure.
Fields inherited from class u6.Heap |
cmp,
height,
size |
Constructor Summary | |
ArrayHeap(java.util.Comparator cmp)
Constructs an empty heap with the specified comparator |
|
ArrayHeap(java.util.Comparator comparator,
Item[] items)
Bottom-Up construction. |
Method Summary | |
void |
add(Item entry)
Adds the given item in the heap and updates the size and the height values. |
void |
bottomUp(int sInx)
Constructs the items of the subarray starting from loInx, i.e. items[sInx..size - 1] into the heap container. |
protected void |
downBubbling()
Restores the order-property of the heap, in the case it's violated by the root. |
protected void |
downBubbling(int index)
Locally restores the order-property at the node with the given (absolute) index and the given last node. |
Item |
extractItem()
Extracts the root of the Heap and updates the size and the height values. |
java.lang.Object |
readMinElement()
Reads the element value of the item, stored in the root of the heap without removing the root. |
java.lang.Object |
readMinKey()
Reads the key, stored in the root of the heap, without extracting the root. |
protected void |
swap(int i,
int j)
Swaps the elements with index i and j. |
java.lang.Object[] |
toArray(java.lang.Object[] a)
|
protected void |
upBubbling()
Restores the order-property of the heap, in the case it's violated by the last node. |
protected void |
upBubbling(int index)
Locally restores the order-property at the node with the given (absolute) index. |
Methods inherited from class u6.Heap |
add,
computeHeight,
getHeight,
isEmpty,
size |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public ArrayHeap(java.util.Comparator cmp)
public ArrayHeap(java.util.Comparator comparator, Item[] items)
items
using an algorithm for bottom-up construction.Method Detail |
public void bottomUp(int sInx)
public void add(Item entry)
size
and the height
values.public Item extractItem()
size
and the height
values.public java.lang.Object readMinKey()
public java.lang.Object readMinElement()
protected void upBubbling()
protected void downBubbling()
protected void upBubbling(int index)
protected void downBubbling(int index)
protected void swap(int i, int j)
public java.lang.Object[] toArray(java.lang.Object[] a)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |