public interface ImmutableHeap<T extends java.lang.Comparable<T>>
extends java.io.Serializable, java.lang.Iterable<T>
Comparable
, and the heap is able to return
the minimum member regarding the relation compareTo
of
T via the method findMin
. Elements of the interface
Heap
are immutable. Implementations of
Heap
have to provide an attribute
EMPTY_HEAP
, which is a singleton representing empty
heaps. Heaps may contain multiple references to one object, or
multiple objects which are equal
.Modifier and Type | Method and Description |
---|---|
ImmutableHeap<T> |
deleteMin()
Remove the minimum element from this heap
|
T |
findMin() |
ImmutableHeap<T> |
insert(ImmutableHeap<T> h)
Add multiple elements to this heap object
|
ImmutableHeap<T> |
insert(java.util.Iterator<T> elements)
Add multiple elements to this heap object
|
ImmutableHeap<T> |
insert(T element)
Add an element to this heap object
|
boolean |
isEmpty() |
ImmutableHeap<T> |
removeAll(T element)
Remove all elements of this heap which are
equal
to element . |
int |
size() |
java.util.Iterator<T> |
sortedIterator() |
boolean isEmpty()
ImmutableHeap<T> insert(T element)
element
- The element to be addedelement
ImmutableHeap<T> insert(java.util.Iterator<T> elements)
elements
- The elements to be addedelements
ImmutableHeap<T> insert(ImmutableHeap<T> h)
h
- a heap containing the elements to be addedh
T findMin()
isEmpty()==true
)ImmutableHeap<T> deleteMin()
ImmutableHeap<T> removeAll(T element)
equal
to element
.element
removedint size()
java.util.Iterator<T> sortedIterator()