Interface DoubleHeap
-
- All Known Implementing Classes:
DoubleMaxHeap,DoubleMinHeap
public interface DoubleHeapBasic in-memory heap for double values.This class is generated from a template.
- Since:
- 0.5.5
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceDoubleHeap.UnsortedIterUnsorted iterator - in heap order.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidadd(double key)Add a key-value pair to the heapvoidadd(double key, int max)Add a key-value pair to the heap, except if the new element is larger than the top, and we are at design size (overflow)voidclear()Delete all elements from the heap.booleanisEmpty()Is the heap empty?doublepeek()Get the current top keydoublepoll()Remove the first elementdoublereplaceTopElement(double e)Combined operation that removes the top element, and inserts a new element instead.intsize()Query the sizeDoubleHeap.UnsortedIterunsortedIter()Get an unsorted iterator to inspect the heap.
-
-
-
Method Detail
-
add
void add(double key)
Add a key-value pair to the heap- Parameters:
key- Key
-
add
void add(double key, int max)Add a key-value pair to the heap, except if the new element is larger than the top, and we are at design size (overflow)- Parameters:
key- Keymax- Maximum size of heap
-
replaceTopElement
double replaceTopElement(double e)
Combined operation that removes the top element, and inserts a new element instead.- Parameters:
e- New element to insert- Returns:
- Previous top element of the heap
-
peek
double peek()
Get the current top key- Returns:
- Top key
-
poll
double poll()
Remove the first element- Returns:
- Top element
-
clear
void clear()
Delete all elements from the heap.
-
size
int size()
Query the size- Returns:
- Size
-
isEmpty
boolean isEmpty()
Is the heap empty?- Returns:
truewhen the size is 0.
-
unsortedIter
DoubleHeap.UnsortedIter unsortedIter()
Get an unsorted iterator to inspect the heap.- Returns:
- Iterator
-
-