T - the type of element to be stored in the soft heappublic class SoftHeap<T> extends java.lang.Object implements SoftPriorityQueue<T>, Meldable<SoftHeap<T>>
SoftPriorityQueue| Modifier and Type | Class and Description |
|---|---|
protected class |
SoftHeap.BinaryHeap
Represents a binary heap in the queue of binary heaps that the soft heap consists of
|
protected class |
SoftHeap.BinaryHeapNode |
| Constructor and Description |
|---|
SoftHeap(double errorRate,
java.util.Comparator<? super T> comparator)
Constructs an empty soft heap with the given error rate.
|
SoftHeap(double errorRate,
java.util.Comparator<? super T> comparator,
T element)
Constructs a new soft heap with the given error rate containing the specified element.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Resets the binary heap
|
java.util.Collection<T> |
corrupted()
Returns a
Collection of corrupted elements -- that is, elements which are associated
with the wrong key. |
void |
insert(T element)
Inserts an element into the queue.
|
void |
meld(SoftHeap<T> other)
Destructively melds other into this.
|
static <S extends java.lang.Comparable<? super S>> |
naturallyOrdered(double errorRate)
Creates a new soft heap on the basis of the comparable type argument and the given error rate.
|
T |
peek()
Peeks into the top of the queue, returning the element which is believed to have
minimal key.
|
T |
pop()
Peeks into the top of the queue, returning the element which is believed to have
minimal key.
|
int |
size()
Returns the size of the queue.
|
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitemptypublic SoftHeap(double errorRate,
java.util.Comparator<? super T> comparator,
T element)
errorRate - the error rate of the soft heapcomparator - used to compare the elements of the soft heap. If T implements
Comparable, you might also use naturallyOrdered(double)element - the element that the SoftHeap should be initialized withpublic SoftHeap(double errorRate,
java.util.Comparator<? super T> comparator)
errorRate - the error rate of the soft heapcomparator - used to compare the elements of the soft heap. If T implements
Comparable, you might also use naturallyOrdered(double)public static <S extends java.lang.Comparable<? super S>> SoftHeap<S> naturallyOrdered(double errorRate)
S - the type of element to be stored in the soft heaperrorRate - the error rate of the soft heappublic int size()
SoftPriorityQueuesize in interface SoftPriorityQueue<T>public java.util.Collection<T> corrupted()
SoftPriorityQueueCollection of corrupted elements -- that is, elements which are associated
with the wrong key.corrupted in interface SoftPriorityQueue<T>Collection of corrupted elementspublic T peek()
SoftPriorityQueuepeek in interface SoftPriorityQueue<T>public T pop()
SoftPriorityQueuepop in interface SoftPriorityQueue<T>public void insert(T element)
SoftPriorityQueueinsert in interface SoftPriorityQueue<T>element - the element to be insertedpublic void clear()
public void meld(SoftHeap<T> other)
Meldablepublic java.lang.String toString()
toString in class java.lang.Object