|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Heap: It's the heap interface.
These heaps implement a decreaseKey operation, which requires
a separate Object to Index map, and for objects to be unique in the Heap.
An interface cannot specify constructors, but it is nevertheless
expected that an implementation of this interface has a constructor
that takes a Comparator, which is used for ordering ("scoring")
objects:
public Heap(Comparator cmp) {}
Method Summary | |
void |
add(Object o)
Adds the object to the heap. |
int |
decreaseKey(Object o)
Raises the priority of an object in the heap. |
Object |
extractMin()
Returns the minimum object, then removes that object from the heap. |
boolean |
isEmpty()
Returns true iff the heap is empty. |
Object |
min()
Returns the minimum Object in this heap. |
int |
size()
The number of elements currently in the heap. |
Method Detail |
public Object extractMin()
public Object min()
public void add(Object o)
o
- a new elementpublic int size()
public boolean isEmpty()
boolean
valuepublic int decreaseKey(Object o)
o
should have
changed with respect to the comparator passed in to the heap on
construction. However, it should NOT have changed with respect
to its equals() method. This is unlike the Java SortedSet where
the comparator should be consistent with equals(); here they
should not match.
o
- an Object
value which has changed wrt the heap's ordering
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |