Spatial C++ Library
Generic Multi-Dimensional Containers and Spatial Operations
mapping_iterator.hpp
1 // -*- C++ -*-
2 //
3 // Copyright Sylvain Bougerel 2009 - 2014.
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file COPYING or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 
13 #ifndef SPATIAL_MAPPING_ITERATOR_HPP
14 #define SPATIAL_MAPPING_ITERATOR_HPP
15 
16 #include <utility> // std::pair
17 #include "spatial.hpp"
18 #include "traits.hpp"
19 #include "bits/spatial_bidirectional.hpp"
20 #include "bits/spatial_rank.hpp"
21 #include "bits/spatial_except.hpp"
22 #include "bits/spatial_assign.hpp"
23 #include "bits/spatial_mapping.hpp"
24 
25 namespace spatial
26 {
27  namespace details
28  {
41  template <typename Container>
42  struct Mapping : Container::key_compare
43  {
45  Mapping() { }
46 
54  Mapping
55  (const typename Container::key_compare& c, dimension_type m)
56  : Container::key_compare(c), mapping_dim(m)
57  { }
58 
59  typename Container::key_compare key_comp() const
60  { return static_cast<typename Container::key_compare>(*this); }
61 
76  };
77  }
78 
92  template<typename Ct>
95  <typename container_traits<Ct>::mode_type,
96  typename container_traits<Ct>::rank_type>
97  {
98  private:
102 
103  public:
104  using Base::node;
105  using Base::node_dim;
106  using Base::rank;
107 
109 
112 
123  mapping_iterator(Ct& container, dimension_type mapping_dim,
124  typename container_traits<Ct>::iterator iter)
125  : Base(container.rank(), iter.node, modulo(iter.node, container.rank())),
126  _data(container.key_comp(), mapping_dim)
127  { except::check_dimension(container.dimension(), mapping_dim); }
128 
151  mapping_iterator(Ct& container, dimension_type mapping_dim,
152  dimension_type dim,
154  : Base(container.rank(), ptr, dim),
155  _data(container.key_comp(), mapping_dim)
156  { except::check_dimension(container.dimension(), mapping_dim); }
157 
161  {
163  increment_mapping(node, node_dim, rank(),
165  return *this;
166  }
167 
171  {
172  mapping_iterator<Ct> x(*this);
174  increment_mapping(node, node_dim, rank(),
176  return x;
177  }
178 
182  {
184  decrement_mapping(node, node_dim, rank(),
186  return *this;
187  }
188 
192  {
193  mapping_iterator<Ct> x(*this);
195  decrement_mapping(node, node_dim, rank(),
197  return x;
198  }
199 
201  key_compare
202  key_comp() const { return _data.key_comp(); }
203 
222  mapping_dimension() const { return _data.mapping_dim; }
226 
227  private:
230  };
231 
247  template<typename Ct>
248  class mapping_iterator<const Ct>
250  <typename container_traits<Ct>::mode_type,
251  typename container_traits<Ct>::rank_type>
252  {
253  private:
257 
258  public:
259  using Base::node;
260  using Base::node_dim;
261  using Base::rank;
262 
265 
268 
279  mapping_iterator(const Ct& container, dimension_type mapping_dim,
281  : Base(container.rank(), iter.node, modulo(iter.node, container.rank())),
282  _data(container.key_comp(), mapping_dim)
283  { except::check_dimension(container.dimension(), mapping_dim); }
284 
311  (const Ct& container, dimension_type mapping_dim, dimension_type dim,
313  : Base(container.rank(), ptr, dim),
314  _data(container.key_comp(), mapping_dim)
315  { except::check_dimension(container.dimension(), mapping_dim); }
316 
319  : Base(iter.rank(), iter.node, iter.node_dim),
320  _data(iter.key_comp(), iter.mapping_dimension()) { }
321 
325  {
327  increment_mapping(node, node_dim, rank(),
329  return *this;
330  }
331 
335  {
338  increment_mapping(node, node_dim, rank(),
340  return x;
341  }
342 
346  {
348  decrement_mapping(node, node_dim, rank(),
350  return *this;
351  }
352 
356  {
359  decrement_mapping(node, node_dim, rank(),
361  return x;
362  }
363 
365  key_compare
366  key_comp() const { return _data.key_comp(); }
367 
386  mapping_dimension() const { return _data.mapping_dim; }
390 
391  private:
394  };
395 
400  template <typename Container>
401  inline dimension_type
403  { return it.mapping_dimension(); }
404 
410  template <typename Container>
411  inline void
413  dimension_type mapping_dim)
414  {
415  except::check_dimension(it.dimension(), mapping_dim);
416  it.mapping_dimension() = mapping_dim;
417  }
418 
441  template <typename Container>
443  inline mapping_iterator<Container>
444  mapping_end(Container& container, dimension_type mapping_dim)
445  {
446  except::check_dimension(container.dimension(), mapping_dim);
448  (container, mapping_dim, container.dimension() - 1,
449  container.end().node); // At header (dim = rank - 1)
450  }
451 
452  template <typename Container>
453  inline mapping_iterator<const Container>
454  mapping_cend(const Container& container, dimension_type mapping_dim)
455  { return mapping_end(container, mapping_dim); }
457 
478  template <typename Container>
480  inline mapping_iterator<Container>
481  mapping_begin(Container& container, dimension_type mapping_dim)
482  {
483  if (container.empty()) return mapping_end(container, mapping_dim);
484  except::check_dimension(container.dimension(), mapping_dim);
486  = container.end().node->parent;
487  dimension_type dim;
488  details::assign(node, dim,
489  minimum_mapping(node, 0,
490  container.rank(), mapping_dim,
491  container.key_comp()));
492  return mapping_iterator<Container>(container, mapping_dim, dim, node);
493  }
494 
495  template <typename Container>
496  inline mapping_iterator<const Container>
497  mapping_cbegin(const Container& container, dimension_type mapping_dim)
498  { return mapping_begin(container, mapping_dim); }
500 
507  template <typename Ct>
509  : std::pair<mapping_iterator<Ct>, mapping_iterator<Ct> >
510  {
515  typedef std::pair<mapping_iterator<Ct>, mapping_iterator<Ct> > Base;
516 
519 
523  const mapping_iterator<Ct>& b) : Base(a, b) { }
524  };
525 
532  template <typename Ct>
533  struct mapping_iterator_pair<const Ct>
534  : std::pair<mapping_iterator<const Ct>, mapping_iterator<const Ct> >
535  {
540  typedef std::pair<mapping_iterator<const Ct>, mapping_iterator<const Ct> >
542 
545 
549  const mapping_iterator<const Ct>& b) : Base(a, b)
550  { }
551 
555  : Base(p.first, p.second) { }
556  };
557 
594  template <typename Container>
595  inline mapping_iterator_pair<Container>
596  mapping_range(Container& container, dimension_type mapping_dim)
597  {
599  (mapping_begin(container, mapping_dim),
600  mapping_end(container, mapping_dim));
601  }
602 
604 
634  template <typename Container>
635  inline mapping_iterator_pair<const Container>
636  mapping_range(const Container& container, dimension_type mapping_dim)
637  {
639  (mapping_begin(container, mapping_dim),
640  mapping_end(container, mapping_dim));
641  }
642 
643  template <typename Container>
644  inline mapping_iterator_pair<const Container>
645  mapping_crange(const Container& container, dimension_type mapping_dim)
646  {
648  (mapping_begin(container, mapping_dim),
649  mapping_end(container, mapping_dim));
650  }
652 
677  template <typename Container>
679  inline mapping_iterator<Container>
680  mapping_lower_bound(Container& container, dimension_type mapping_dim,
682  bound)
683  {
684  if (container.empty()) return mapping_end(container, mapping_dim);
685  except::check_dimension(container.dimension(), mapping_dim);
687  = container.end().node->parent;
688  dimension_type dim;
689  details::assign(node, dim,
690  lower_bound_mapping(node, 0, container.rank(), mapping_dim,
691  container.key_comp(), bound));
692  return mapping_iterator<Container>(container, mapping_dim, dim, node);
693  }
694 
695  template <typename Container>
696  inline mapping_iterator<const Container>
698  (const Container& container, dimension_type mapping_dim,
699  const typename container_traits<Container>::key_type& bound)
700  { return mapping_lower_bound(container, mapping_dim, bound); }
702 
727  template <typename Container>
729  inline mapping_iterator<Container>
731  (Container& container, dimension_type mapping_dim,
732  const typename container_traits<Container>::key_type& bound)
733  {
734  if (container.empty()) return mapping_end(container, mapping_dim);
735  except::check_dimension(container.dimension(), mapping_dim);
737  = container.end().node->parent;
738  dimension_type dim;
739  details::assign(node, dim,
740  upper_bound_mapping(node, 0, container.rank(), mapping_dim,
741  container.key_comp(), bound));
742  return mapping_iterator<Container>(container, mapping_dim, dim, node);
743  }
744 
745  template <typename Container>
746  inline mapping_iterator<const Container>
748  (const Container& container, dimension_type mapping_dim,
749  const typename container_traits<Container>::key_type& bound)
750  { return mapping_upper_bound(container, mapping_dim, bound); }
752 
753  namespace details
754  {
759  template <typename KeyCompare, typename Key>
761  inline bool
763  (KeyCompare key_comp, dimension_type map, const Key& x, const Key& y,
765  { return key_comp(map, x, y); }
766 
767  template <typename KeyCompare, typename Key>
768  inline bool
770  (KeyCompare key_comp, dimension_type map, const Key& x, const Key& y,
772  { return !key_comp(map, y, x); }
774 
800  template <typename NodePtr, typename Rank, typename KeyCompare>
801  inline std::pair<NodePtr, dimension_type>
803  (NodePtr node, dimension_type dim, Rank rank, dimension_type map,
804  KeyCompare key_comp)
805  {
806  SPATIAL_ASSERT_CHECK(dim < rank());
807  SPATIAL_ASSERT_CHECK(!header(node));
808  NodePtr orig = node;
809  dimension_type orig_dim = dim;
810  NodePtr best = 0;
811  dimension_type best_dim = 0;
812  // Look forward to find an equal or greater next best
813  // If an equal next best is found, then no need to look further
814  for (;;)
815  {
816  if (node->right != 0
817  && (dim != map || best == 0
818  || key_comp(map, const_key(node), const_key(best))))
819  {
820  node = node->right; dim = incr_dim(rank, dim);
821  while (node->left != 0
822  && (dim != map
824  (key_comp, map, const_key(orig), const_key(node),
825  invariant_category(node))))
826  { node = node->left; dim = incr_dim(rank, dim); }
827  }
828  else
829  {
830  NodePtr prev_node = node;
831  node = node->parent; dim = decr_dim(rank, dim);
832  while (!header(node)
833  && prev_node == node->right)
834  {
835  prev_node = node;
836  node = node->parent; dim = decr_dim(rank, dim);
837  }
838  if (header(node)) break;
839  }
840  if (key_comp(map, const_key(orig), const_key(node)))
841  {
842  if (best == 0 || key_comp(map, const_key(node), const_key(best)))
843  { best = node; best_dim = dim; }
844  }
845  else if (!key_comp(map, const_key(node), const_key(orig)))
846  {
847  SPATIAL_ASSERT_CHECK(dim < rank());
848  SPATIAL_ASSERT_CHECK(!header(node));
849  return std::make_pair(node, dim);
850  }
851  }
852  SPATIAL_ASSERT_CHECK(dim == rank() - 1);
853  SPATIAL_ASSERT_CHECK(header(node));
854  // Maybe there is a better best looking backward...
855  node = orig;
856  dim = orig_dim;
857  for (;;)
858  {
859  if (node->left != 0
860  && (dim != map
861  || key_comp(map, const_key(orig), const_key(node))))
862  {
863  node = node->left; dim = incr_dim(rank, dim);
864  while (node->right != 0
865  && (dim != map || best == 0
866  || key_comp(map, const_key(node), const_key(best))))
867  { node = node->right; dim = incr_dim(rank, dim); }
868  }
869  else
870  {
871  NodePtr prev_node = node;
872  node = node->parent; dim = decr_dim(rank, dim);
873  while (!header(node)
874  && prev_node == node->left)
875  {
876  prev_node = node;
877  node = node->parent; dim = decr_dim(rank, dim);
878  }
879  if (header(node)) break;
880  }
881  if (key_comp(map, const_key(orig), const_key(node))
882  && (best == 0
883  || !key_comp(map, const_key(best), const_key(node))))
884  { best = node; best_dim = dim; }
885  }
886  if (best != 0)
887  { node = best; dim = best_dim; }
888  SPATIAL_ASSERT_CHECK(dim < rank());
889  SPATIAL_ASSERT_CHECK((best == 0 && header(node))
890  || (best != 0 && !header(node)));
891  return std::make_pair(node, dim);
892  }
893 
922  template <typename NodePtr, typename Rank, typename KeyCompare>
923  inline std::pair<NodePtr, dimension_type>
925  (NodePtr node, dimension_type dim, Rank rank, dimension_type map,
926  KeyCompare key_comp)
927  {
928  SPATIAL_ASSERT_CHECK(dim < rank());
929  if (header(node))
930  return maximum_mapping(node->parent, 0, rank, map, key_comp);
931  NodePtr orig = node;
932  dimension_type orig_dim = dim;
933  NodePtr best = 0;
934  dimension_type best_dim = 0;
935  // Look backward to find an equal or greater next best
936  // If an equal next best is found, then no need to look further
937  for (;;)
938  {
939  if (node->left != 0
940  && (dim != map || best == 0
941  || key_comp(map, const_key(best), const_key(node))))
942  {
943  node = node->left; dim = incr_dim(rank, dim);
944  while (node->right != 0
945  && (dim != map
946  || !key_comp(map, const_key(orig), const_key(node))))
947  { node = node->right; dim = incr_dim(rank, dim); }
948  }
949  else
950  {
951  NodePtr prev_node = node;
952  node = node->parent; dim = decr_dim(rank, dim);
953  while (!header(node)
954  && prev_node == node->left)
955  {
956  prev_node = node;
957  node = node->parent; dim = decr_dim(rank, dim);
958  }
959  if (header(node)) break;
960  }
961  if (key_comp(map, const_key(node), const_key(orig)))
962  {
963  if (best == 0 || key_comp(map, const_key(best), const_key(node)))
964  { best = node; best_dim = dim; }
965  }
966  else if (!key_comp(map, const_key(orig), const_key(node)))
967  {
968  SPATIAL_ASSERT_CHECK(dim < rank());
969  SPATIAL_ASSERT_CHECK(!header(node));
970  return std::make_pair(node, dim);
971  }
972  }
973  SPATIAL_ASSERT_CHECK(dim == rank() - 1);
974  SPATIAL_ASSERT_CHECK(header(node));
975  // Maybe there is a better best looking forward...
976  node = orig;
977  dim = orig_dim;
978  for (;;)
979  {
980  if (node->right != 0
981  && (dim != map
982  || key_comp(map, const_key(node), const_key(orig))))
983  {
984  node = node->right; dim = incr_dim(rank, dim);
985  while (node->left != 0
986  && (dim != map || best == 0
987  || key_comp(map, const_key(best), const_key(node))))
988  { node = node->left; dim = incr_dim(rank, dim); }
989  }
990  else
991  {
992  NodePtr prev_node = node;
993  node = node->parent; dim = decr_dim(rank, dim);
994  while (!header(node)
995  && prev_node == node->right)
996  {
997  prev_node = node;
998  node = node->parent; dim = decr_dim(rank, dim);
999  }
1000  if (header(node)) break;
1001  }
1002  if (key_comp(map, const_key(node), const_key(orig))
1003  && (best == 0
1004  || !key_comp(map, const_key(node), const_key(best))))
1005  { best = node; best_dim = dim; }
1006  }
1007  if (best != 0)
1008  { node = best; dim = best_dim; }
1009  SPATIAL_ASSERT_CHECK(dim < rank());
1010  SPATIAL_ASSERT_CHECK((best == 0 && header(node))
1011  || (best != 0 && !header(node)));
1012  return std::make_pair(node, dim);
1013  }
1014 
1043  template <typename NodePtr, typename Rank, typename KeyCompare,
1044  typename KeyType>
1045  inline std::pair<NodePtr, dimension_type>
1047  (NodePtr node, dimension_type dim, Rank rank, dimension_type map,
1048  KeyCompare key_comp, const KeyType& bound)
1049  {
1050  SPATIAL_ASSERT_CHECK(map < rank());
1051  SPATIAL_ASSERT_CHECK(dim < rank());
1052  SPATIAL_ASSERT_CHECK(!header(node));
1053  while (node->left != 0
1054  && (dim != map
1055  || left_compare_mapping(key_comp, map, bound, const_key(node),
1056  invariant_category(node))))
1057  { node = node->left; dim = incr_dim(rank, dim); }
1058  NodePtr best = 0;
1059  dimension_type best_dim;
1060  if (!key_comp(map, const_key(node), bound))
1061  { best = node; best_dim = dim; }
1062  for (;;)
1063  {
1064  if (node->right != 0 && (dim != map || best == 0))
1065  {
1066  node = node->right;
1067  dim = incr_dim(rank, dim);
1068  while (node->left != 0
1069  && (dim != map
1070  || left_compare_mapping(key_comp, map, bound,
1071  const_key(node),
1072  invariant_category(node))))
1073  { node = node->left; dim = incr_dim(rank, dim); }
1074  }
1075  else
1076  {
1077  NodePtr prev_node = node;
1078  node = node->parent;
1079  dim = decr_dim(rank, dim);
1080  while (!header(node)
1081  && prev_node == node->right)
1082  {
1083  prev_node = node;
1084  node = node->parent; dim = decr_dim(rank, dim);
1085  }
1086  if (header(node)) break;
1087  }
1088  if (!key_comp(map, const_key(node), bound)
1089  && (best == 0 || key_comp(map, const_key(node), const_key(best))))
1090  { best = node; best_dim = dim; }
1091  }
1092  SPATIAL_ASSERT_CHECK(dim == rank() - 1);
1093  SPATIAL_ASSERT_CHECK(best != node);
1094  SPATIAL_ASSERT_CHECK(header(node));
1095  if (best == 0)
1096  { best = node; best_dim = dim; }
1097  return std::make_pair(best, best_dim);
1098  }
1099 
1128  template <typename NodePtr, typename Rank, typename KeyCompare,
1129  typename KeyType>
1130  inline std::pair<NodePtr, dimension_type>
1132  (NodePtr node, dimension_type dim, Rank rank, dimension_type map,
1133  KeyCompare key_comp, const KeyType& bound)
1134  {
1135  SPATIAL_ASSERT_CHECK(map < rank());
1136  SPATIAL_ASSERT_CHECK(dim < rank());
1137  SPATIAL_ASSERT_CHECK(!header(node));
1138  while (node->left != 0
1139  && (dim != map
1140  || key_comp(map, bound, const_key(node))))
1141  { node = node->left; dim = incr_dim(rank, dim); }
1142  NodePtr best = 0;
1143  dimension_type best_dim;
1144  if (key_comp(map, bound, const_key(node)))
1145  { best = node; best_dim = dim; }
1146  for (;;)
1147  {
1148  if (node->right != 0 && (dim != map || best == 0))
1149  {
1150  node = node->right;
1151  dim = incr_dim(rank, dim);
1152  while (node->left != 0
1153  && (dim != map
1154  || key_comp(map, bound, const_key(node))))
1155  { node = node->left; dim = incr_dim(rank, dim); }
1156  }
1157  else
1158  {
1159  NodePtr prev_node = node;
1160  node = node->parent;
1161  dim = decr_dim(rank, dim);
1162  while (!header(node)
1163  && prev_node == node->right)
1164  {
1165  prev_node = node;
1166  node = node->parent; dim = decr_dim(rank, dim);
1167  }
1168  if (header(node)) break;
1169  }
1170  if (key_comp(map, bound, const_key(node))
1171  && (best == 0 || key_comp(map, const_key(node), const_key(best))))
1172  { best = node; best_dim = dim; }
1173  }
1174  SPATIAL_ASSERT_CHECK(dim == rank() - 1);
1175  SPATIAL_ASSERT_CHECK(best != node);
1176  SPATIAL_ASSERT_CHECK(header(node));
1177  if (best == 0)
1178  { best = node; best_dim = dim; }
1179  return std::make_pair(best, best_dim);
1180  }
1181 
1182  } // namespace details
1183 }
1184 
1185 #endif // SPATIAL_MAPPING_ITERATOR_HPP
details::Mapping< Ct > _data
The related data for the iterator.
details::Mapping< Ct > _data
The related data for the iterator.
dimension_type mapping_dimension() const
Accessor to the mapping dimension used by the iterator.
mapping_iterator< const Container > mapping_clower_bound(const Container &container, dimension_type mapping_dim, const typename container_traits< Container >::key_type &bound)
Finds the value with the smallest coordinate along the mapping dimension that is greater or equal to ...
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...
mapping_iterator_pair< Container > mapping_range(Container &container, dimension_type mapping_dim)
Returns a pair of iterator on the first and the last value in the range that can be iterated...
container_traits< Ct >::key_compare key_compare
mapping_iterator(const Ct &container, dimension_type mapping_dim, typename container_traits< Ct >::const_iterator iter)
The standard way to build this iterator: specify a mapping dimension, an iterator on a container...
mapping_iterator< Container > mapping_upper_bound(Container &container, dimension_type mapping_dim, const typename container_traits< Container >::key_type &bound)
Finds the value with the largest coordinate along the mapping dimension that is stricly less than bou...
This structure defines a pair of mutable mapping iterator.
const rank_type & rank() const
Return the current Rank type used by the iterator.
dimension_type mapping_dim
The current dimension of iteration.
Link::invariant_category invariant_category(const Node< Link > *)
For a given node, this function returns the invariant category of the node.
std::pair< NodePtr, dimension_type > decrement_mapping(NodePtr node, dimension_type dim, Rank rank, dimension_type map, KeyCompare key_comp)
Move the pointer given in parameter to the previous element in the ordered iteration of values along ...
node_ptr node
The pointer to the current node.
mapping_iterator< Ct > operator--(int)
Decrements the iterator but returns the value of the iterator before the decrement.
void check_dimension(dimension_type rank, dimension_type dimension)
Checks that dimension is not greater or equal to rank.
This iterator walks through all items in the container in order from the lowest to the highest value ...
mapping_iterator< const Container > mapping_cupper_bound(const Container &container, dimension_type mapping_dim, const typename container_traits< Container >::key_type &bound)
Finds the value with the largest coordinate along the mapping dimension that is stricly less than bou...
dimension_type dimension() const
Return the number of dimensions stored by the Rank of the iterator.
std::pair< mapping_iterator< Ct >, mapping_iterator< Ct > > Base
A pair of iterators that represents a range (that is: a range of elements to iterate, and not an orthogonal range).
std::pair< mapping_iterator< const Ct >, mapping_iterator< const Ct > > Base
A pair of iterators that represents a range (that is: a range of elements to iterate, and not an orthogonal range).
mapping_iterator_pair< const Container > mapping_crange(const Container &container, dimension_type mapping_dim)
Returns a pair of constant iterator on the first and the last value in the range that can be iterated...
dimension_type mapping_dimension() const
Accessor to the mapping dimension used by the iterator.
mapping_iterator< Container > mapping_end(Container &container, dimension_type mapping_dim)
Finds the past-the-end position in container for this constant iterator.
key_compare key_comp() const
Return the key_comparator used by the iterator.
Tp::key_type key_type
The type representing the key managed by the container.
Definition: traits.hpp:48
mapping_iterator< const Ct > & operator--()
Decrements the iterator and returns the decremented value.
container_traits< Ct >::key_compare key_compare
Alias for the key_compare type used by the iterator.
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.
mapping_iterator()
Build an uninitialized iterator.
dimension_type node_dim
The dimension of the current node.
bool header(const Node< Link > *x)
Check if node is a header node.
key_compare key_comp() const
Return the key_comparator used by the iterator.
Container::key_compare key_comp() const
std::pair< NodePtr, dimension_type > lower_bound_mapping(NodePtr node, dimension_type dim, Rank rank, dimension_type map, KeyCompare key_comp, const KeyType &bound)
Move the iterator given in parameter to the value with the smallest coordinate greater or equal to bo...
mapping_iterator_pair(const mapping_iterator_pair< Ct > &p)
Convert a mutable mapping iterator pair into a const mapping iterator pair.
details::Const_bidirectional_iterator< typename container_traits< Ct >::mode_type, typename container_traits< Ct >::rank_type > Base
mapping_iterator< const Container > mapping_cbegin(const Container &container, dimension_type mapping_dim)
Finds the value in container for which its key has the smallest coordinate over the dimension mapping...
mapping_iterator< Container > mapping_lower_bound(Container &container, dimension_type mapping_dim, const typename container_traits< Container >::key_type &bound)
Finds the value with the smallest coordinate along the mapping dimension that is greater or equal to ...
mapping_iterator< Ct > & operator++()
Increments the iterator and returns the incremented value.
mapping_iterator< const Ct > & operator++()
Increments the iterator and returns the incremented value.
mapping_iterator< Ct > & operator--()
Decrements the iterator and returns the decremented value.
The traits type for all containers in the spatial namespace.
Definition: traits.hpp:42
container_traits< Ct >::mode_type::node_ptr node_ptr
The type for the node pointed to by the iterator.
std::size_t dimension_type
Defines the type for the dimension as being a size.
Definition: spatial.hpp:71
mapping_iterator< const Ct > operator--(int)
Decrements the iterator but returns the value of the iterator before the decrement.
dimension_type & mapping_dimension()
Accessor to the mapping dimension used by the iterator.
mapping_iterator_pair(const mapping_iterator< const Ct > &a, const mapping_iterator< const Ct > &b)
Regular constructor that builds a mapping_iterator_pair out of 2 mapping_iterators.
The category of invariants for a k-d tree node: strict or relaxed.
void assign(Type1 &first, Type2 &second, const std::pair< Type1, Type2 > &pair)
details::Bidirectional_iterator< typename container_traits< Ct >::mode_type, typename container_traits< Ct >::rank_type > Base
std::pair< NodePtr, dimension_type > maximum_mapping(NodePtr node, dimension_type dim, Rank rank, dimension_type map, KeyCompare key_comp)
Move the iterator given in parameter to the maximum value along the iterator's mapping dimension but ...
The main namespace used in the library.
Definition: algorithm.hpp:23
std::pair< NodePtr, dimension_type > upper_bound_mapping(NodePtr node, dimension_type dim, Rank rank, dimension_type map, KeyCompare key_comp, const KeyType &bound)
Move the iterator given in parameter to the value with the largest coordinate strictly lower than bou...
dimension_type decr_dim(Rank rank, dimension_type node_dim)
Decrement dimension node_dim, given rank.
mapping_iterator_pair(const mapping_iterator< Ct > &a, const mapping_iterator< Ct > &b)
Regular constructor that builds a mapping_iterator_pair out of 2 mapping_iterators.
mapping_iterator(const mapping_iterator< Ct > &iter)
Convertion of mutable iterator into a constant iterator is permitted.
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...
A common template for constant bidirectional iterators that work on identical modes of linking...
std::pair< NodePtr, dimension_type > increment_mapping(NodePtr node, dimension_type dim, Rank rank, dimension_type map, KeyCompare key_comp)
Move the pointer given in parameter to the next element in the ordered iteration of values along the ...
A common template for bidirectional iterators that work on identical modes of linking.
bool left_compare_mapping(KeyCompare key_comp, dimension_type map, const Key &x, const Key &y, strict_invariant_tag)
This function provides a common interface for the two k-d tree invariants.
Mapping()
Build an uninitialized mapping data object.
Extra information needed by the iterator to perform its work.
mapping_iterator_pair()
Empty constructor.
mapping_iterator< const Ct > operator++(int)
Increments the iterator but returns the value of the iterator before the increment.
mapping_iterator< Container > mapping_begin(Container &container, dimension_type mapping_dim)
Finds the value in container for which its key has the smallest coordinate over the dimension mapping...
mapping_iterator()
Uninitialized iterator.
This iterator walks through all items in the container in order from the lowest to the highest value ...
mapping_iterator< Ct > operator++(int)
Increments the iterator but returns the value of the iterator before the increment.
dimension_type mapping_dimension(const mapping_iterator< Container > &it)
Return the mapping dimension of the iterator.
dimension_type & mapping_dimension()
Accessor to the mapping dimension used by the iterator.
dimension_type incr_dim(Rank rank, dimension_type node_dim)
Increment dimension node_dim, given rank.
mapping_iterator< const Container > mapping_cend(const Container &container, dimension_type mapping_dim)
Finds the past-the-end position in container for this constant iterator.