private static class ImmutableLeftistHeap.Node<S extends java.lang.Comparable<S>> extends ImmutableLeftistHeap<S>
Modifier and Type | Field and Description |
---|---|
private S |
data |
private ImmutableLeftistHeap<S> |
left
Children of the root of this heap
|
private ImmutableLeftistHeap<S> |
right |
private int |
rightHeight
Length of the right spine, i.e. the length of the path from the
root to rightmost leaf
|
private static long |
serialVersionUID |
private int |
size |
Modifier | Constructor and Description |
---|---|
|
Node(S element)
Node constructor for nodes with only empty children
|
|
Node(S element,
ImmutableLeftistHeap<S> a)
Node constructor for nodes with at most one non-empty child
|
private |
Node(S element,
ImmutableLeftistHeap<S> a,
ImmutableLeftistHeap<S> b)
Node constructor for nodes
|
Modifier and Type | Method and Description |
---|---|
ImmutableHeap<S> |
deleteMin()
Remove the minimum element from this heap
|
S |
findMin() |
protected int |
getRightHeight()
Length of the right spine, i.e. the length of the path from the
root to rightmost leaf
|
ImmutableHeap<S> |
insert(ImmutableHeap<S> h)
Add multiple elements to this heap object
|
ImmutableHeap<S> |
insert(S element)
Add an element to this heap object
|
boolean |
isEmpty() |
ImmutableHeap<S> |
removeAll(S element)
Remove all elements of this heap which are
equal
to element . |
int |
size() |
insert, iterator, nilHeap, sortedIterator, toString
private static final long serialVersionUID
private final int rightHeight
private final int size
private final ImmutableLeftistHeap<S extends java.lang.Comparable<S>> left
private final ImmutableLeftistHeap<S extends java.lang.Comparable<S>> right
public Node(S element)
public Node(S element, ImmutableLeftistHeap<S> a)
private Node(S element, ImmutableLeftistHeap<S> a, ImmutableLeftistHeap<S> b)
protected int getRightHeight()
getRightHeight
in class ImmutableLeftistHeap<S extends java.lang.Comparable<S>>
public boolean isEmpty()
public ImmutableHeap<S> insert(S element)
element
- the element to be addedelement
public ImmutableHeap<S> insert(ImmutableHeap<S> h)
h
- a heap containing the elements to be addedh
public S findMin()
isEmpty()==true
)public ImmutableHeap<S> deleteMin()
public ImmutableHeap<S> removeAll(S element)
equal
to element
.element
removedpublic int size()