Template Struct NearestNeighbors

Struct Documentation

template<typename Iterator, typename Compare = std::less<typename Iterator::value_type>>
struct NearestNeighbors

Gets the elements nearest to the specified value in the container.

The container must have random access iterators and be ordered.

Public Types

using T = typename Iterator::value_type

Type used to order the container.

Public Functions

inline std::pair<Iterator, Iterator> get(Iterator begin, Iterator end, const T &t) const
Parameters
  • begin – The beginning of the container search.

  • end – The end (one past the last element) of the container search.

  • t – The element to find neighbors of.

Returns

Pair of iterators representing the nearest elements to t. If t is before all elements then return will be {end, begin}; if t is after all elements return will be {end - 1, end}. If t is exactly matched, both iterators will be to the last such element that matched t. Finally, if t is between two elements then the return will be the elements before and after t.