Template Function mrpt::containers::find_closest_with_tolerance

Function Documentation

template<typename Container>
std::optional<std::pair<typename Container::key_type, typename Container::mapped_type>> mrpt::containers::find_closest_with_tolerance(const Container &data, const typename Container::key_type x, const typename Container::key_type tolerance)

For an associate container Container mapping real number keys to T values, searchs for the closest key within a given tolerance, that is, the key closest to x within the interval [x-tolerace, x+tolerance]. An empty std::optional is returned if none is found.

Computational cost: O(log(N)+M) with N the total size of the container, M the worst-case number of items in any interval of width 2*tolerance.

See also

find_closest()

Note

(New in MRPT 2.5.0)