Spatial C++ Library
Generic Multi-Dimensional Containers and Spatial Operations
spatial::mapping_iterator< Ct > Class Template Reference

This iterator walks through all items in the container in order from the lowest to the highest value along a particular dimension. More...

#include <mapping_iterator.hpp>

Inherits spatial::details::Bidirectional_iterator< container_traits< Ct >::mode_type, container_traits< Ct >::rank_type >.

Public Types

typedef container_traits< Ct >::key_compare key_compare
 
- 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

 mapping_iterator ()
 Uninitialized iterator. More...
 
 mapping_iterator (Ct &container, dimension_type mapping_dim, typename container_traits< Ct >::iterator iter)
 The standard way to build this iterator: specify a mapping dimension, an iterator on a container, and that container. More...
 
 mapping_iterator (Ct &container, dimension_type mapping_dim, dimension_type dim, typename container_traits< Ct >::mode_type::node_ptr ptr)
 When the information of the dimension for the current node being pointed to by the iterator is known, this function saves some CPU cycle, by comparison to the other. More...
 
mapping_iterator< Ct > & operator++ ()
 Increments the iterator and returns the incremented value. More...
 
mapping_iterator< Ct > operator++ (int)
 Increments the iterator but returns the value of the iterator before the increment. More...
 
mapping_iterator< Ct > & operator-- ()
 Decrements the iterator and returns the decremented value. More...
 
mapping_iterator< Ct > 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...
 
dimension_type mapping_dimension () const
 Accessor to the mapping dimension used by the iterator. More...
 
dimension_typemapping_dimension ()
 Accessor to the mapping dimension used by 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_typerank () 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_typeBase
 

Private Attributes

details::Mapping< Ct > _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...
 

Detailed Description

template<typename Ct>
class spatial::mapping_iterator< Ct >

This iterator walks through all items in the container in order from the lowest to the highest value along a particular dimension.

The key_comp comparator of the container is used for comparision.

In effect, that makes any container of the library behave as a std::set or std::map. Through this iterator, a spatial container with 3 dimensions can provide the same features as 3 std::set(s) or std::map(s) containing the same elements and ordered on each of these dimensions. Beware that iteration through the tree is very efficient when the dimension k-d tree is very small by comparison to the number of objects, but pretty inefficient otherwise, by comparison to a std::set.

Definition at line 93 of file mapping_iterator.hpp.

Member Typedef Documentation

template<typename Ct>
typedef details::Bidirectional_iterator<typename container_traits<Ct>::mode_type, typename container_traits<Ct>::rank_type> spatial::mapping_iterator< Ct >::Base
private

Definition at line 101 of file mapping_iterator.hpp.

template<typename Ct>
typedef container_traits<Ct>::key_compare spatial::mapping_iterator< Ct >::key_compare

Definition at line 108 of file mapping_iterator.hpp.

Constructor & Destructor Documentation

template<typename Ct>
spatial::mapping_iterator< Ct >::mapping_iterator ( )

Uninitialized iterator.

Definition at line 111 of file mapping_iterator.hpp.

template<typename Ct>
spatial::mapping_iterator< Ct >::mapping_iterator ( Ct &  container,
dimension_type  mapping_dim,
typename container_traits< Ct >::iterator  iter 
)

The standard way to build this iterator: specify a mapping dimension, an iterator on a container, and that container.

Parameters
containerThe container to iterate.
mapping_dimThe dimension used to order all nodes during the iteration.
iterUse the value of iter as the start point for the iteration.

Definition at line 123 of file mapping_iterator.hpp.

template<typename Ct>
spatial::mapping_iterator< Ct >::mapping_iterator ( Ct &  container,
dimension_type  mapping_dim,
dimension_type  dim,
typename container_traits< Ct >::mode_type::node_ptr  ptr 
)

When the information of the dimension for the current node being pointed to by the iterator is known, this function saves some CPU cycle, by comparison to the other.

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().

Attention
Specifying the incorrect dimension value for the node will result in unknown behavior. It is recommended that you do not use this constructor if you are not sure about this dimension, and use the other constructors instead.
Parameters
containerThe container to iterate.
mapping_dimThe dimension used to order all nodes during the iteration.
dimThe dimension of the node pointed to by iterator.
ptrUse the value of node as the start point for the iteration.

Definition at line 151 of file mapping_iterator.hpp.

Member Function Documentation

template<typename Ct>
key_compare spatial::mapping_iterator< Ct >::key_comp ( ) const

Return the key_comparator used by the iterator.

Definition at line 202 of file mapping_iterator.hpp.

template<typename Ct>
dimension_type spatial::mapping_iterator< Ct >::mapping_dimension ( ) const

Accessor to the mapping dimension used by the iterator.

No check is performed on this accessor if a new mapping dimension is given. If you need to check that the mapping dimension given does not exceed the rank use the function spatial::mapping_dimension() instead:

// Create a mapping iterator that works on dimension 0
mapping_iterator<my_container> iter (begin_mapping(container, 0));
// Reset the mapping iterator to work on dimension 2
// This will throw if the container used has a rank lower than 3.

Definition at line 222 of file mapping_iterator.hpp.

template<typename Ct>
dimension_type& spatial::mapping_iterator< Ct >::mapping_dimension ( )

Accessor to the mapping dimension used by the iterator.

No check is performed on this accessor if a new mapping dimension is given. If you need to check that the mapping dimension given does not exceed the rank use the function spatial::mapping_dimension() instead:

// Create a mapping iterator that works on dimension 0
mapping_iterator<my_container> iter (begin_mapping(container, 0));
// Reset the mapping iterator to work on dimension 2
// This will throw if the container used has a rank lower than 3.

Definition at line 224 of file mapping_iterator.hpp.

template<typename Ct>
mapping_iterator<Ct>& spatial::mapping_iterator< Ct >::operator++ ( )

Increments the iterator and returns the incremented value.

Prefer to use this form in for loops.

Definition at line 160 of file mapping_iterator.hpp.

template<typename Ct>
mapping_iterator<Ct> spatial::mapping_iterator< Ct >::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 170 of file mapping_iterator.hpp.

template<typename Ct>
mapping_iterator<Ct>& spatial::mapping_iterator< Ct >::operator-- ( )

Decrements the iterator and returns the decremented value.

Prefer to use this form in for loops.

Definition at line 181 of file mapping_iterator.hpp.

template<typename Ct>
mapping_iterator<Ct> spatial::mapping_iterator< Ct >::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 191 of file mapping_iterator.hpp.

Member Data Documentation

template<typename Ct>
details::Mapping<Ct> spatial::mapping_iterator< Ct >::_data
private

The related data for the iterator.

Definition at line 229 of file mapping_iterator.hpp.


The documentation for this class was generated from the following file: