Spatial C++ Library
Generic Multi-Dimensional Containers and Spatial Operations
Difference

This concept defines the requirements for objects to be used in nearest neighbor queries with the library's built-in metrics such as spatial::euclidian, spatial::quadrance or spatial::manhattan.

The models of Difference are used to calculate the difference between 2 keys along the same dimension. That difference is expressed in a Unit chosen by the user. Very often, the difference consist in a simple substraction of the coordinates of 2 keys along the dimenion specified.

The models of Difference shall publicly provide the following interfaces:

Signature/TypedefDescription
Legend D A model of Difference
Legend K The key type of a spatial container.
Legend Unit The type unit chosen to express a difference.
Require Unit D::operator()(spatial::dimension_type dim, const K& x, const K& y) const Returns the difference (or very often, the substraction) of x minus y along the dimension dim.

If you have build your current container based on spatial::paren_less, spatial::bracket_less, spatial::iterator_less or spatial::accessor_less, and if you wish to use your container for nearest neighbor search, then you might not need to define a new Difference functor: the library will be able to deduce the right functor, based on the comparators used in the container.

Class spatial::accessor_minus< Accessor, Tp, Unit >
This object is a model of Difference
Class spatial::bracket_minus< Tp, Unit >
This object is a model of Difference
Class spatial::iterator_minus< Tp, Unit >
This object is a model of Difference
Class spatial::paren_minus< Tp, Unit >
This object is a model of Difference