Interface IntegerObjectHeap<V>
-
- Type Parameters:
V- Value type
- All Known Implementing Classes:
IntegerObjectMaxHeap,IntegerObjectMinHeap
public interface IntegerObjectHeap<V>Basic in-memory heap interface, for int keys and Object values.This class is generated from a template.
- Since:
- 0.6.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceIntegerObjectHeap.UnsortedIter<V>Unsorted iterator - in heap order.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidadd(int key, V val)Add a key-value pair to the heapvoidadd(int key, V val, int k)Add a key-value pair to the heap if it improves the top.voidclear()Clear the heap contents.booleancontainsKey(int q)Contains operation for a key (slow: with a linear scan).booleancontainsValue(V q)Contains operation for a value (slow: with a linear scan).booleanisEmpty()Is the heap empty?intpeekKey()Get the current top key.VpeekValue()Get the current top value.voidpoll()Remove the first element.voidreplaceTopElement(int key, V val)Combined operation that removes the top element, and inserts a new element instead.intsize()Query the size.IntegerObjectHeap.UnsortedIter<V>unsortedIter()Get an unsorted iterator to inspect the heap.
-
-
-
Method Detail
-
add
void add(int key, V val)Add a key-value pair to the heap- Parameters:
key- Keyval- Value
-
add
void add(int key, V val, int k)Add a key-value pair to the heap if it improves the top.- Parameters:
key- Keyval- Valuek- Desired maximum size
-
replaceTopElement
void replaceTopElement(int key, V val)Combined operation that removes the top element, and inserts a new element instead.- Parameters:
key- Key of new elementval- Value of new element
-
peekKey
int peekKey()
Get the current top key.- Returns:
- Top key
-
peekValue
V peekValue()
Get the current top value.- Returns:
- Value
-
containsKey
boolean containsKey(int q)
Contains operation for a key (slow: with a linear scan).- Parameters:
q- Key- Returns:
trueif the key is contained in the heap.
-
containsValue
boolean containsValue(V q)
Contains operation for a value (slow: with a linear scan).- Parameters:
q- Value- Returns:
trueif the value is contained in the heap.
-
poll
void poll()
Remove the first element.
-
clear
void clear()
Clear the heap contents.
-
size
int size()
Query the size.- Returns:
- Size
-
isEmpty
boolean isEmpty()
Is the heap empty?- Returns:
truewhen the size is 0.
-
unsortedIter
IntegerObjectHeap.UnsortedIter<V> unsortedIter()
Get an unsorted iterator to inspect the heap.- Returns:
- Iterator
-
-