BoundedHeap
Parameters
TType of elements stored in the heap
Public Methods
| Return | Name | Description |
|---|---|---|
BoundedHeap | Construct a bounded heap. | |
void | insert | Insert an element into the heap. |
const T * | peek const | Peek at the worst (highest-distance) element in the heap. |
std::vector< T > | to_sorted const | Extract all elements sorted by distance. |
std::size_t | size const | Get current number of elements in heap. |
bool | empty const | Check if heap is empty. |
BoundedHeap
inline
Parameters
-
limitMaximum number of elements to retain -
distDistance function - lower values are preferred
Exceptions
std::invalid_argumentIf limit < 1
insert
inline
Parameters
entryElement to insert
peek
const
Returns
Pointer to root element (max distance), or nullptr if empty :::note The returned pointer is invalid after insert() or destruction :::to_sorted
const
Returns
Vector of elements sorted from best to worst :::note Returns copy of elements; original heap is unchanged :::size
const
Returns
Number of elements (0 to limit_)empty
const
Public Types
| Name | Description |
|---|---|
DistFn | Distance function type. |
DistFn
Private Attributes
data_
limit_
dist_
Private Methods
sift_up
inline
sift_down
inline