|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--Heap
An implementation of a heap. Elements stored in the heap must implement the Comparable interface.
| Constructor Summary | |
Heap()
Construct a heap with initial capacity 10 and capacity increment 0 |
|
Heap(int c)
Construct a heap with initial capacity c and capacity increment 0 |
|
Heap(int c,
int ci)
Construct a heap with initial capacity c and capacity increment ci |
|
| Method Summary | |
int |
capacity()
Return the capacity of the heap |
void |
insert(java.lang.Comparable value)
Insert an element into the heap |
java.lang.Comparable |
remove()
Remove top element from the heap |
int |
size()
Return the size of the heap |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Heap()
public Heap(int c)
c - initial capacity for heap
java.lang.IllegalArgumentException - c is negative
public Heap(int c,
int ci)
c - initial capacity for heapci - capacity increment for heap
java.lang.IllegalArgumentException - c or ci is negative| Method Detail |
public int size()
public int capacity()
public void insert(java.lang.Comparable value)
value - object to insert
java.lang.IllegalArgumentException - value is null
public java.lang.Comparable remove()
throws EmptyHeapException
EmptyHeapException - heap is empty
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||