15 #ifndef SPATIAL_EQUAL_HPP 
   16 #define SPATIAL_EQUAL_HPP 
   18 #include "spatial_bidirectional.hpp" 
   19 #include "../traits.hpp" 
   20 #include "spatial_rank.hpp" 
   21 #include "spatial_except.hpp" 
   22 #include "spatial_compress.hpp" 
   23 #include "spatial_preorder.hpp" 
   29     template <
typename Container>
 
   30     struct Equal : 
private Container::key_compare 
 
   34       Equal(
const typename Container::key_compare& cmp,
 
   35             const typename Container::key_type& value_)
 
   36         : Container::key_compare(cmp), 
value(value_) { }
 
   38       typename Container::key_compare 
key_comp()
 const 
   39       { 
return *
static_cast<const typename Container::key_compare*
>(
this); }
 
   41       typename Container::key_type 
value;
 
   44     template <
typename Container>
 
   67     template <
typename Container>
 
   70                     typename Container::rank_type rank,
 
   81     template <
typename Container>
 
   91     template <
typename Container>
 
  101     template <
typename Container>
 
  109          typename Container::mode_type::invariant_category());
 
  122   template <
typename Container>
 
  125       <typename container_traits<Container>::mode_type,
 
  126        typename container_traits<Container>::rank_type>
 
  163       : Base(container.rank(), iter.node, modulo(iter.node, container.rank())),
 
  187       : 
Base(container.rank(), ptr, dim), 
_query(container.key_comp(), value_)
 
  195                       preorder_increment(node, node_dim, rank(), 
_query));
 
  205                       preorder_increment(node, node_dim, rank(), 
_query));
 
  214                       preorder_decrement(node, node_dim, rank(), 
_query));
 
  224                       preorder_decrement(node, node_dim, rank(), 
_query));
 
  248   template <
typename Container>
 
  251       <typename container_traits<Container>::mode_type,
 
  252        typename container_traits<Container>::rank_type>
 
  257     <
typename container_traits<Container>::mode_type,
 
  289       : Base(container.rank(), iter.node, modulo(iter.node, container.rank())),
 
  310       : 
Base(container.rank(), ptr, dim), 
_query(container.key_comp(), value_)
 
  315       : Base(iter.rank(), iter.node, iter.node_dim),
 
  323                       preorder_increment(node, node_dim, rank(), 
_query));
 
  333                       preorder_increment(node, node_dim, rank(), 
_query));
 
  342                       preorder_decrement(node, node_dim, rank(), 
_query));
 
  352                       preorder_decrement(node, node_dim, rank(), 
_query));
 
  367   template <
typename Container>
 
  373       (container, value, container.dimension() - 1,
 
  374        container.end().node); 
 
  377   template <
typename Container>
 
  378   inline equal_iterator<const Container>
 
  392   template <
typename Container>
 
  394   inline equal_iterator<Container>
 
  398     if (container.empty()) 
return equal_end(container, value);
 
  400       = container.end().node->parent;
 
  403                     first_equal(node, 0, container.rank(),
 
  408   template <
typename Container>
 
  409   inline equal_iterator<const Container>
 
  417     template <
typename NodePtr, 
typename Rank, 
typename KeyCompare, 
typename Key>
 
  418     inline std::pair<NodePtr, dimension_type>
 
  420                 KeyCompare key_comp, 
const Key& key)
 
  423       NodePtr end = node->parent;
 
  428           bool walk_left = !key_comp(dim, 
const_key(node), key);
 
  429           bool walk_right = !key_comp(dim, key, 
const_key(node));
 
  430           if (walk_left && walk_right)
 
  433               for (; test < dim && !(key_comp(test, key, 
const_key(node))
 
  434                                      || key_comp(test, 
const_key(node), key)); ++test);
 
  438                   for (; test < rank() && !(key_comp(test, key, 
const_key(node))
 
  439                                             || key_comp(test, 
const_key(node), key)); ++test);
 
  441                     { 
return std::make_pair(node, dim); }
 
  445           if (walk_left && node->left != 0)
 
  447               if (walk_right && node->right != 0)
 
  454                                      rank, key_comp, key));
 
  456                     { 
return std::make_pair(other, other_dim); }
 
  458                     { node = node->right; dim = 
incr_dim(rank, dim); }
 
  461                 { node = node->left; dim = 
incr_dim(rank, dim); }
 
  463           else if (walk_right && node->right != 0)
 
  464             { node = node->right; dim = 
incr_dim(rank, dim); }
 
  465           else { 
return std::make_pair(end, end_dim); }
 
  472 #endif // SPATIAL_EQUAL_HPP 
equal_iterator(const Container &container, const key_type &value_, typename container_traits< Container >::const_iterator iter)
Build an equal iterator from a container's iterator type. 
bool stop_traversal(typename Container::mode_type::const_node_ptr node, typename Container::rank_type rank, const Equal< Container > &equal)
Return a boolean indicating whether all of x's coordinates are equal to y's coordinates. 
std::pair< NodePtr, dimension_type > first_equal(NodePtr node, dimension_type dim, Rank rank, KeyCompare key_comp, const Key &key)
equal_iterator()
Constructs an empty, uninitialized object. 
const rank_type & rank() const 
Return the current Rank type used by the iterator. 
bool right_traversal(typename Container::mode_type::const_node_ptr node, dimension_type dim, const Equal< Container > &equal)
node_ptr node
The pointer to the current node. 
equal_iterator< const Container > & operator--()
Decrements the iterator and returns the decremented value. 
Tp::key_compare key_compare
Comparison functor used to compare two instances of key_type. 
equal_iterator< Container > operator++(int)
Increments the iterator but returns the value of the iterator before the increment. 
details::Equal< Container > _query
The model key used to find equal keys in the container. 
Container::key_compare key_comp() const 
key_compare key_comp() const 
Returns the functor used to compare keys in this iterator. 
This type provides an iterator to iterate through all elements of a container that match a given key...
This type provides an iterator to iterate through all elements of a container that match a given key...
Tp::iterator iterator
The type used to iterate a container. 
Tp::key_type key_type
The type representing the key managed by the container. 
const Kdtree_link< Value, Value >::key_type & const_key(const Node< Kdtree_link< Value, Value > > *node)
This function converts a pointer on a node into a key for a Kdtree_link type. 
dimension_type node_dim
The dimension of the current node. 
container_traits< Container >::key_compare key_compare
The comparison functor used to compare keys. 
Container::key_type value
details::Equal< Container > _query
The model key used to find equal keys in the container. 
equal_iterator()
Constructs an empty, uninitialized object. 
equal_iterator< const Container > operator++(int)
Increments the iterator but returns the value of the iterator before the increment. 
equal_iterator< Container > & operator--()
Decrements the iterator and returns the decremented value. 
Equal(const typename Container::key_compare &cmp, const typename Container::key_type &value_)
Tp::const_iterator const_iterator
The type used to iterate a constant container. 
key_compare key_comp() const 
Return the functor used to compare keys in this iterator. 
The traits type for all containers in the spatial namespace. 
Tp::mode_type mode_type
The Link Mode type that is associated with the container. 
std::size_t dimension_type
Defines the type for the dimension as being a size. 
equal_iterator(const equal_iterator< Container > &iter)
Convertion of an iterator into a const_iterator is permitted. 
Tp::rank_type rank_type
The type used to represent the rank of the container. 
container_traits< Container >::key_compare key_compare
The comparison functor used to compare keys. 
details::Bidirectional_iterator< typename container_traits< Container >::mode_type, typename container_traits< Container >::rank_type > Base
The preorder iterator without its criterion. 
The category of invariants for a k-d tree node: strict or relaxed. 
equal_iterator< Container > & operator++()
Increments the iterator and returns the incremented value. 
void assign(Type1 &first, Type2 &second, const std::pair< Type1, Type2 > &pair)
key_type value() const 
Return the value of key used to find equal keys in the container. 
The main namespace used in the library. 
dimension_type decr_dim(Rank rank, dimension_type node_dim)
Decrement dimension node_dim, given rank. 
equal_iterator(Container &container, const key_type &value_, typename container_traits< Container >::iterator iter)
Build an equal iterator from a container's iterator type. 
equal_iterator< const Container > operator--(int)
Decrements the iterator but returns the value of the iterator before the decrement. 
equal_iterator< const Container > equal_cbegin(const Container &container, const typename equal_iterator< Container >::key_type &value)
Find the first element in container that compares equally to value, using container's key_compare com...
equal_iterator< Container > equal_end(Container &container, const typename equal_iterator< Container >::key_type &value)
equal_iterator< const Container > equal_cend(const Container &container, const typename equal_iterator< Container >::key_type &value)
A common template for constant bidirectional iterators that work on identical modes of linking...
A common template for bidirectional iterators that work on identical modes of linking. 
equal_iterator< const Container > & operator++()
Increments the iterator and returns the incremented value. 
details::Const_bidirectional_iterator< typename container_traits< Container >::mode_type, typename container_traits< Container >::rank_type > Base
The preorder iterator without its criterion. 
container_traits< Container >::key_type key_type
The type used to store the model key to be looked up in the container. 
equal_iterator< Container > operator--(int)
Decrements the iterator but returns the value of the iterator before the decrement. 
equal_iterator< Container > equal_begin(Container &container, const typename equal_iterator< Container >::key_type &value)
Find the first element in container that compares equally to value, using container's key_compare com...
container_traits< Container >::key_type key_type
The type used to store the model key to be looked up in the container. 
dimension_type incr_dim(Rank rank, dimension_type node_dim)
Increment dimension node_dim, given rank. 
bool left_traversal(typename Container::mode_type::const_node_ptr node, dimension_type dim, const Equal< Container > &equal, relaxed_invariant_tag)
key_type value() const 
Returns the value used to find equivalent keys in the container.