Package elki.database.ids
Interface DoubleDBIDHeap
-
- All Superinterfaces:
DBIDRef
- All Known Subinterfaces:
KNNHeap
- All Known Implementing Classes:
DoubleIntegerDBIDHeap
,DoubleIntegerDBIDKNNHeap
public interface DoubleDBIDHeap extends DBIDRef
Max heap for DBIDs.To instantiate, use:
DBIDUtil.newMaxHeap(int)
!- Since:
- 0.5.5
- Author:
- Erich Schubert
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
clear()
Clear the heap.boolean
contains(DBIDRef other)
Check if an object is already in the heap (slow scan).double
insert(double key, DBIDRef id)
Add a double-id pair to the heapdouble
insert(double distance, DBIDRef id, int max)
Add a double-id pair to the heap unless the heap grows beyond the given maximum size.default boolean
isEmpty()
Test if the heap is empty.double
peekKey()
Get the topmost value (the heap is aDBIDRef
, referencing the top element).void
poll()
Remove the topmost element.int
size()
Current size of heap.DoubleDBIDIter
unorderedIterator()
Unordered iterator over the heap.-
Methods inherited from interface elki.database.ids.DBIDRef
equals, hashCode, internalGetIndex
-
-
-
-
Method Detail
-
peekKey
double peekKey()
Get the topmost value (the heap is aDBIDRef
, referencing the top element).- Returns:
- value at top
-
poll
void poll()
Remove the topmost element.
-
insert
double insert(double key, DBIDRef id)
Add a double-id pair to the heap- Parameters:
key
- Key valueid
- ID number- Returns:
- Value of to the element at the top of the heap
-
insert
double insert(double distance, DBIDRef id, int max)
Add a double-id pair to the heap unless the heap grows beyond the given maximum size. Beware of the following subtle details:- If the heap has fewer than "max" elements, the value is added.
- else, if the new value is "worse" than the top, it will replace the top (and the heap will be repaired)
- for a min heap, this adds only larger value, for a max heap only smaller values. This may seem odd, but it is equivalent to adding the new element and then removing the top ("best") element.
- But: the heap will not be reduced to the given size
- Parameters:
distance
- Distance valueid
- ID numbermax
- Maximum number of values- Returns:
- Distance to the element at the top of the heap
-
size
int size()
Current size of heap.- Returns:
- Heap size
-
isEmpty
default boolean isEmpty()
Test if the heap is empty.- Returns:
- true when empty.
-
clear
void clear()
Clear the heap.
-
unorderedIterator
DoubleDBIDIter unorderedIterator()
Unordered iterator over the heap.- Returns:
- Iterator
-
contains
boolean contains(DBIDRef other)
Check if an object is already in the heap (slow scan).- Parameters:
other
- Other object- Returns:
true
if contained
-
-