Template Class NeighborsHeap

Class Documentation

template<typename T>
class NeighborsHeap

A class for tracking k-nearest neighbors. Implemented as a min-heap with a limited size.

Template Parameters

T – type of distance (usually double)

Public Functions

inline NeighborsHeap(size_t limit)

Constructor.

Parameters

limit – the maximum heap size.

Throws

std::invalid_argument – if the limit is less than or equal to zero.

inline void add(T value)

Add a new value. Also remove the largest value if the heap size is exceeding the specified limit.

Parameters

value – a new value.

inline const T &peek() const

Returns the largest value in the heap.

Returns

the largest value.

inline std::vector<T> extract()