Spatial C++ Library
Generic Multi-Dimensional Containers and Spatial Operations
|
A spatial iterator for a container Ct
that goes through the nearest to the furthest element from a target key, with distances applied according to a user-defined geometric space that is a model of Metric.
More...
#include <spatial_neighbor.hpp>
Public Types | |
typedef container_traits< Ct >::key_compare | key_compare |
Key comparator type transferred from the container. More... | |
typedef Metric | metric_type |
The metric type used by the iterator. More... | |
typedef Metric::distance_type | distance_type |
The distance type that is read from metric_type. More... | |
typedef container_traits< Ct >::key_type | key_type |
The key type that is used as a target for the nearest neighbor search. More... | |
Public Types inherited from spatial::details::Bidirectional_iterator< container_traits< Ct >::mode_type, container_traits< Ct >::rank_type > | |
typedef mutate< typename container_traits< Ct >::mode_type::value_type >::type | value_type |
The value_type can receive a copy of the reference pointed to be the iterator. More... | |
typedef container_traits< Ct >::mode_type::value_type & | reference |
The reference type of the object pointed to by the iterator. More... | |
typedef container_traits< Ct >::mode_type::value_type * | pointer |
The pointer type of the object pointed to by the iterator. More... | |
typedef std::ptrdiff_t | difference_type |
The difference_type returned by the distance between 2 iterators. More... | |
typedef std::bidirectional_iterator_tag | iterator_category |
The iterator category that is always Bidirectional_iterator_tag . More... | |
typedef container_traits< Ct >::mode_type::node_ptr | node_ptr |
The type for the node pointed to by the iterator. More... | |
typedef container_traits< Ct >::rank_type | rank_type |
The type of rank used by the iterator. More... | |
typedef container_traits< Ct >::mode_type::invariant_category | invariant_category |
The invariant category of the the iterator. More... | |
Public Member Functions | |
neighbor_iterator () | |
Uninitialized iterator. More... | |
neighbor_iterator (Ct &container_, const Metric &metric_, const typename container_traits< Ct >::key_type &target_, const typename container_traits< Ct >::iterator &iter_, typename Metric::distance_type distance_) | |
The standard way to build this iterator: specify a metric to apply, an iterator on a container, and that container. More... | |
neighbor_iterator (Ct &container_, const Metric &metric_, const typename container_traits< Ct >::key_type &target_, dimension_type node_dim_, typename container_traits< Ct >::mode_type::node_ptr node_, typename Metric::distance_type distance_) | |
When the information of the dimension for the current node being pointed to by the iterator is known, this constructor saves some CPU cycle, by comparison to the other constructor. More... | |
neighbor_iterator (const typename container_traits< Ct >::rank_type &rank_, const typename container_traits< Ct >::key_compare &key_comp_, const Metric &metric_, const typename container_traits< Ct >::key_type &target_, dimension_type node_dim_, typename container_traits< Ct >::mode_type::node_ptr node_, typename Metric::distance_type distance_) | |
Build the iterator with a given rank and key compare functor, if the container is not available. More... | |
neighbor_iterator< Ct, Metric > & | operator++ () |
Increments the iterator and returns the incremented value. More... | |
neighbor_iterator< Ct, Metric > | operator++ (int) |
Increments the iterator but returns the value of the iterator before the increment. More... | |
neighbor_iterator< Ct, Metric > & | operator-- () |
Decrements the iterator and returns the decremented value. More... | |
neighbor_iterator< Ct, Metric > | operator-- (int) |
Decrements the iterator but returns the value of the iterator before the decrement. More... | |
key_compare | key_comp () const |
Return the key_comparator used by the iterator. More... | |
metric_type | metric () const |
Return the metric used by the iterator. More... | |
const distance_type & | distance () const |
Read-only accessor to the last valid distance of the iterator. More... | |
distance_type & | distance () |
Read/write accessor to the last valid distance of the iterator. More... | |
const key_type & | target_key () const |
Read-only accessor to the target of the iterator. More... | |
key_type & | target_key () |
Read/write accessor to the target of the iterator. More... | |
Public Member Functions inherited from spatial::details::Bidirectional_iterator< container_traits< Ct >::mode_type, container_traits< Ct >::rank_type > | |
Bidirectional_iterator () | |
Build an uninitialized iterator. More... | |
Bidirectional_iterator (const container_traits< Ct >::rank_type &rank_, node_ptr node_, dimension_type node_dim_) | |
Initialize the node at construction time. More... | |
reference | operator* () |
Returns the reference to the value pointed to by the iterator. More... | |
pointer | operator-> () |
Returns a pointer to the value pointed to by the iterator. More... | |
bool | operator== (const Const_node_iterator< container_traits< Ct >::mode_type > &x) const |
A bidirectional iterator can be compared with a node iterator if they work on identical linking modes. More... | |
bool | operator!= (const Const_node_iterator< container_traits< Ct >::mode_type > &x) const |
A bidirectional iterator can be compared for inequality with a node iterator if they work on identical linking modes. More... | |
const rank_type & | rank () const |
Return the current Rank type used by the iterator. More... | |
dimension_type | dimension () const |
Return the number of dimensions stored by the Rank of the iterator. More... | |
operator Node_iterator< container_traits< Ct >::mode_type > () const | |
This iterator can be casted silently into a container iterator. More... | |
operator Const_node_iterator< container_traits< Ct >::mode_type > () const | |
This iterator can be casted silently into a container iterator. More... | |
Private Types | |
typedef details::Bidirectional_iterator< typename container_traits< Ct >::mode_type, typename container_traits< Ct >::rank_type > | Base |
Private Attributes | |
details::Neighbor_data< Ct, Metric > | _data |
The related data for the iterator. More... | |
Additional Inherited Members | |
Public Attributes inherited from spatial::details::Bidirectional_iterator< container_traits< Ct >::mode_type, container_traits< Ct >::rank_type > | |
node_ptr | node |
The pointer to the current node. More... | |
dimension_type | node_dim |
The dimension of the current node. More... | |
A spatial iterator for a container Ct
that goes through the nearest to the furthest element from a target key, with distances applied according to a user-defined geometric space that is a model of Metric.
Ct | The container type bound to the iterator. |
DistanceType | The type used to represent distances. |
Metric | An type that is a model of Metric. |
The Metric type is a complex type that must be a model of Metric:
The details of the Metric
type are explained in Metric. The library provides ready-made models of Metric
such as spatial::euclidian and spatial::manhattan that are designed to work only with C++'s built-in arithmetic types. If more metrics needs to be defined, see the explanation in the Metric concept.
Definition at line 115 of file spatial_neighbor.hpp.
|
private |
Definition at line 123 of file spatial_neighbor.hpp.
typedef Metric::distance_type spatial::neighbor_iterator< Ct, Metric >::distance_type |
The distance type that is read from metric_type.
Definition at line 137 of file spatial_neighbor.hpp.
typedef container_traits<Ct>::key_compare spatial::neighbor_iterator< Ct, Metric >::key_compare |
Key comparator type transferred from the container.
Definition at line 131 of file spatial_neighbor.hpp.
typedef container_traits<Ct>::key_type spatial::neighbor_iterator< Ct, Metric >::key_type |
The key type that is used as a target for the nearest neighbor search.
Definition at line 140 of file spatial_neighbor.hpp.
typedef Metric spatial::neighbor_iterator< Ct, Metric >::metric_type |
The metric type used by the iterator.
Definition at line 134 of file spatial_neighbor.hpp.
spatial::neighbor_iterator< Ct, Metric >::neighbor_iterator | ( | ) |
Uninitialized iterator.
Definition at line 143 of file spatial_neighbor.hpp.
spatial::neighbor_iterator< Ct, Metric >::neighbor_iterator | ( | Ct & | container_, |
const Metric & | metric_, | ||
const typename container_traits< Ct >::key_type & | target_, | ||
const typename container_traits< Ct >::iterator & | iter_, | ||
typename Metric::distance_type | distance_ | ||
) |
The standard way to build this iterator: specify a metric to apply, an iterator on a container, and that container.
container_ | The container to iterate. |
metric_ | The Metric applied during the iteration. |
target_ | The target of the neighbor iteration. |
iter_ | An iterator on container. |
distance_ | The distance at which the node pointed by iterator is from target. |
Definition at line 157 of file spatial_neighbor.hpp.
spatial::neighbor_iterator< Ct, Metric >::neighbor_iterator | ( | Ct & | container_, |
const Metric & | metric_, | ||
const typename container_traits< Ct >::key_type & | target_, | ||
dimension_type | node_dim_, | ||
typename container_traits< Ct >::mode_type::node_ptr | node_, | ||
typename Metric::distance_type | distance_ | ||
) |
When the information of the dimension for the current node being pointed to by the iterator is known, this constructor saves some CPU cycle, by comparison to the other constructor.
container_ | The container to iterate. |
metric_ | The metric applied during the iteration. |
target_ | The target of the neighbor iteration. |
node_dim_ | The dimension of the node pointed to by iterator. |
node_ | Use the value of node as the start point for the iteration. |
distance_ | The distance between node_ and target_ according to metric_ . |
In order to iterate through nodes in the k-d tree built in the container, the algorithm must know at each node which dimension is used to partition the space. Some algorithms will provide this dimension, such as the function spatial::details::modulo().
Definition at line 190 of file spatial_neighbor.hpp.
spatial::neighbor_iterator< Ct, Metric >::neighbor_iterator | ( | const typename container_traits< Ct >::rank_type & | rank_, |
const typename container_traits< Ct >::key_compare & | key_comp_, | ||
const Metric & | metric_, | ||
const typename container_traits< Ct >::key_type & | target_, | ||
dimension_type | node_dim_, | ||
typename container_traits< Ct >::mode_type::node_ptr | node_, | ||
typename Metric::distance_type | distance_ | ||
) |
Build the iterator with a given rank and key compare functor, if the container is not available.
In order to iterate through nodes in the k-d tree built in the container, the algorithm must know at each node which dimension is used to partition the space. Some algorithms will provide this dimension, such as the function spatial::details::modulo().
rank_ | The rank of the container being iterated. |
key_comp_ | The key compare functor associated with the iterator. |
metric_ | The metric applied during the iteration. |
target_ | The target of the neighbor iteration. |
node_dim_ | The dimension of the node pointed to by iterator. |
node_ | Use the value of node as the start point for the iteration. |
distance_ | The distance between node_ and target_ according to metric_ . |
Definition at line 223 of file spatial_neighbor.hpp.
const distance_type& spatial::neighbor_iterator< Ct, Metric >::distance | ( | ) | const |
Read-only accessor to the last valid distance of the iterator.
Definition at line 285 of file spatial_neighbor.hpp.
distance_type& spatial::neighbor_iterator< Ct, Metric >::distance | ( | ) |
Read/write accessor to the last valid distance of the iterator.
Definition at line 289 of file spatial_neighbor.hpp.
key_compare spatial::neighbor_iterator< Ct, Metric >::key_comp | ( | ) | const |
Return the key_comparator used by the iterator.
Definition at line 277 of file spatial_neighbor.hpp.
metric_type spatial::neighbor_iterator< Ct, Metric >::metric | ( | ) | const |
Return the metric used by the iterator.
Definition at line 281 of file spatial_neighbor.hpp.
neighbor_iterator<Ct, Metric>& spatial::neighbor_iterator< Ct, Metric >::operator++ | ( | ) |
Increments the iterator and returns the incremented value.
Prefer to use this form in for
loops.
Definition at line 235 of file spatial_neighbor.hpp.
neighbor_iterator<Ct, Metric> spatial::neighbor_iterator< Ct, Metric >::operator++ | ( | int | ) |
Increments the iterator but returns the value of the iterator before the increment.
Prefer to use the other form in for
loops.
Definition at line 245 of file spatial_neighbor.hpp.
neighbor_iterator<Ct, Metric>& spatial::neighbor_iterator< Ct, Metric >::operator-- | ( | ) |
Decrements the iterator and returns the decremented value.
Prefer to use this form in for
loops.
Definition at line 256 of file spatial_neighbor.hpp.
neighbor_iterator<Ct, Metric> spatial::neighbor_iterator< Ct, Metric >::operator-- | ( | int | ) |
Decrements the iterator but returns the value of the iterator before the decrement.
Prefer to use the other form in for
loops.
Definition at line 266 of file spatial_neighbor.hpp.
const key_type& spatial::neighbor_iterator< Ct, Metric >::target_key | ( | ) | const |
Read-only accessor to the target of the iterator.
Definition at line 293 of file spatial_neighbor.hpp.
key_type& spatial::neighbor_iterator< Ct, Metric >::target_key | ( | ) |
Read/write accessor to the target of the iterator.
Definition at line 297 of file spatial_neighbor.hpp.
|
private |
The related data for the iterator.
Definition at line 301 of file spatial_neighbor.hpp.