15 #ifndef SPATIAL_ALGORITHM_HPP
16 #define SPATIAL_ALGORITHM_HPP
19 #include <bits/spatial_node.hpp>
20 #include <bits/spatial_assert.hpp>
21 #include "spatial.hpp"
37 template <
typename Container>
38 inline std::pair<std::size_t>
41 typename Container::const_iterator::node_ptr node
42 = Container.end().node->parent;
43 SPATIAL_ASSERT(node != 0);
44 SPATIAL_ASSERT(node == node->parent->parent);
45 if (header(node))
return pair<std::size_t>(0, 0);
46 std::size_t current = 1;
47 while (node->left != 0)
48 { ++current; node = node->left; }
50 std::size_t min = current, max = curent;
55 node = node->right; ++current;
56 while (node->left != 0) { node = node->left; ++current; }
57 if (current > max) max = current;
58 if (current < min) min = current;
62 if (current > max) max = current;
63 if (current < min) min = current;
64 Node<Mode>* p = node->parent;
65 while (!header(p) && node == p->right)
66 { node = p; p = node->parent; --current; }
68 SPATIAL_ASSERT(max >= min);
69 SPATIAL_ASSERT(max >= 1);
70 SPATIAL_ASSERT(min >= 1);
73 return std::pair<std::size_t>(min, max);
83 template <
typename Iterator>
84 inline std::size_t
depth(
const Iterator& iterator)
86 typename Iterator::node_ptr node = iterator.node;
87 std::size_t
depth = 0;
89 { node = node->parent; ++
depth; }
93 #endif // SPATIAL_ALGORITHM_HPP
std::size_t depth(const Iterator &iterator)
Returns the depth of a node's iterator.
std::pair< std::size_t > minmax_depth(const Container &container)
Returns a pair containing the minimum (as first) and maximum (as second) depth found in the container...
The main namespace used in the library.