|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Heap<E>
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 | |
---|---|
boolean |
add(E o)
Adds the object to the heap. |
int |
decreaseKey(E o)
Raises the priority of an object in the heap. |
E |
extractMin()
Returns the minimum object, then removes that object from the heap. |
boolean |
isEmpty()
Returns true iff the heap is empty. |
Iterator<E> |
iterator()
Returns an iterator over its elements, in order. |
E |
min()
Returns the minimum Object in this heap. |
int |
size()
The number of elements currently in the heap. |
Method Detail |
---|
E extractMin()
E min()
boolean add(E o)
o
- a new element
int size()
boolean isEmpty()
boolean
valueint decreaseKey(E 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
Iterator<E> iterator()
Iterator
value
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |