|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object heaps.generic.GenericHeap<E>
E
- the type of all heap elementspublic abstract class GenericHeap<E>
An extension of the Heap
interface that provides methods for
adding, removing, and querying the membership of heap elements. Whether
duplicates are allowed, as well as the running time of the add
,
contains
, and remove
methods, is dependent on
the backing implementation. An object of type E
is said to be
a duplicate of some other object if the equals method between them returns
true
.
Method Summary | |
---|---|
abstract boolean |
add(E element)
Adds the object element to the heap. |
abstract boolean |
allowsDuplicates()
Returns whether this heap allows duplicate elements. |
abstract boolean |
contains(E element)
Returns whether the heap contains the argument element . |
java.util.Comparator<? super E> |
getComparator()
Returns the comparator associated with this heap, or null
if it uses its elements' natural ordering. |
abstract boolean |
remove(E element)
Finds the object in the heap equal to element , removes
it, and returns true . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface heaps.Heap |
---|
clear, extract, getSize, isEmpty, top |
Method Detail |
---|
public final java.util.Comparator<? super E> getComparator()
null
if it uses its elements' natural ordering.
public abstract boolean add(E element)
element
to the heap. If the implementing
heap allows duplicates, element
is always added to the
heap and this method returns true
. If the implementing
heap does not allow duplicates, element
is added and
method returns true
only if no duplicate of
element
exists in the heap. Otherwise, if a duplicate
exists in the heap and none are allowed, this method returns
false
and the heap remains unchanged.
element
- the object to add to the heap
true
if element
is added,
false
otherwisepublic abstract boolean contains(E element)
element
.
element
- the element to query for membership in the heap
true
if element
is in the heap,
false
otherwisepublic abstract boolean remove(E element)
element
, removes
it, and returns true
. If no such object exists, this
method returns false
and the heap remains unchanged. Note
that if duplicates are allowed in the heap, any one of the duplicates of
element
could be removed.
element
- the element to remove from the heap
true
if element
is removed,
false
otherwisepublic abstract boolean allowsDuplicates()
true
if this heap permits duplicates,
false
otherwise
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |