Find closest utility functions
// global functions 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 double x, double tolerance ); template <typename Container> std::optional<std::pair<typename Container::key_type, typename Container::mapped_type>> mrpt::containers::find_closest( const Container& data, const double x );
Global Functions
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 double x, double 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
.
(New in MRPT 2.5.0)
See also:
template <typename Container> std::optional<std::pair<typename Container::key_type, typename Container::mapped_type>> mrpt::containers::find_closest( const Container& data, const double x )
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, i.e. if the container was empty.
Computational cost: O(log(N))
with N
the total size of the container.
(New in MRPT 2.5.0)
See also: