Yggdrasill  0.2
dynamic_segment_tree.hpp
1 //
2 // Created by lukas on 10.11.17.
3 //
4 
5 #ifndef YGG_DYNAMIC_SEGMENT_TREE_HPP
6 #define YGG_DYNAMIC_SEGMENT_TREE_HPP
7 
8 #include "debug.hpp"
9 #include "options.hpp"
10 #include "rbtree.hpp"
11 #include "size_holder.hpp"
12 #include "util.hpp"
13 #include "wbtree.hpp"
14 #include "ziptree.hpp"
15 
16 namespace ygg {
17 
18 // Forwards
19 template <class Node, class NodeTraits, class Combiners, class Options,
20  class TreeSelector, class Tag>
22 
23 namespace dyn_segtree_internal {
24 
25 /* Interface for when modification sequences should be stored for benchmarking
26  * purposes */
27 template <class InnerNode, class KeyT_in>
29 public:
30  using KeyT = KeyT_in;
31 
32  static KeyT_in
33  get_key(const InnerNode & n) noexcept
34  {
35  return n.get_point();
36  }
37 
38  static KeyT_in
39  get_key(const KeyT_in query) noexcept
40  {
41  return query;
42  }
43 
44  static KeyT_in
45  get_key(const std::pair<KeyT_in, bool> & query) noexcept
46  {
47  return std::get<0>(query);
48  }
49 };
51 
52 // Forwards
53 template <class InnerNode>
54 class Compare;
55 template <class InnerTree, class InnerNode, class Node, class NodeTraits>
56 class InnerRBNodeTraits;
57 template <class InnerTree, class InnerNode, class AggValueT>
58 class InnerZNodeTraits;
59 template <class InnerTree, class InnerNode, class Node, class AggValueT>
60 class InnerWBNodeTraits;
61 
62 template <class Tag>
63 class InnerRBTTag {
64 };
65 
66 template <class Tag>
67 class InnerZTTag {
68 };
69 
70 template <class Tag>
71 class InnerWBTTag {
72 };
73 
74 /********************************************
75  * Base Class Definitions for RBTree
76  ********************************************/
77 template <class... AdditionalOptions>
78 struct UseRBTree
79 {
80  template <class InnerNode, class KeyT>
81  using Options = TreeOptions<TreeFlags::MULTIPLE,
82  TreeFlags::BENCHMARK_SEQUENCE_INTERFACE<
84  AdditionalOptions...>;
85 
86  template <class Tag>
87  struct InnerNodeBaseBuilder
88  {
89  template <class InnerNodeCRTP, class KeyT>
90  using Base =
92  };
93 
94  template <class CRTP, class Node, class NodeTraits, class InnerNode,
95  class Tag>
96  using BaseTree =
97  RBTree<InnerNode,
98  dyn_segtree_internal::InnerRBNodeTraits<CRTP, InnerNode, Node,
99  NodeTraits>,
100  Options<InnerNode, typename InnerNode::KeyT>,
101  dyn_segtree_internal::InnerRBTTag<Tag>, Compare<InnerNode>>;
102 
103  template <class TagType>
104  using Tag = InnerRBTTag<TagType>;
105 };
106 
107 /********************************************
108  * Base Class Definitions for WBTree
109  ********************************************/
110 template <class... AdditionalOptions>
111 struct UseWBTree
112 {
113  template <class InnerNode, class KeyT>
114  using Options = TreeOptions<TreeFlags::MULTIPLE, TreeFlags::WBT_SINGLE_PASS,
115  TreeFlags::BENCHMARK_SEQUENCE_INTERFACE<
117  AdditionalOptions...>;
118 
119  template <class Tag>
120  struct InnerNodeBaseBuilder
121  {
122  template <class InnerNodeCRTP, class KeyT>
124  Tag>; // TODO make options passable here
125  };
126 
127  template <class CRTP, class Node, class NodeTraits, class InnerNode,
128  class Tag>
129  using BaseTree =
130  WBTree<InnerNode,
131  dyn_segtree_internal::InnerWBNodeTraits<CRTP, InnerNode, Node,
132  NodeTraits>,
133  Options<InnerNode, typename InnerNode::KeyT>,
134  dyn_segtree_internal::InnerWBTTag<Tag>, Compare<InnerNode>>;
135 
136  template <class TagType>
137  using Tag = InnerWBTTag<TagType>;
138 };
139 
140 /********************************************
141  * Base Class Definitions for Zip Tree
142  ********************************************/
143 template <class... AdditionalOptions>
144 struct UseZipTree
145 {
146  template <class InnerNode, class KeyT>
147  using Options =
148  TreeOptions<TreeFlags::MULTIPLE, TreeFlags::ZTREE_RANK_TYPE<uint8_t>,
149  TreeFlags::BENCHMARK_SEQUENCE_INTERFACE<
151  AdditionalOptions...>;
152  template <class Tag>
153  struct InnerNodeBaseBuilder
154  {
155  template <class InnerNodeCRTP, class KeyT>
156  using Base =
158  };
159 
160  template <class CRTP, class Node, class NodeTraits, class InnerNode,
161  class Tag>
162  using BaseTree =
163  ZTree<InnerNode,
164  dyn_segtree_internal::InnerZNodeTraits<
165  CRTP, InnerNode, typename InnerNode::AggValueT>,
166  Options<InnerNode, typename InnerNode::KeyT>,
167  dyn_segtree_internal::InnerZTTag<Tag>, Compare<InnerNode>>;
168 
169  template <class TagType>
170  using Tag = InnerZTTag<TagType>;
171 };
173 
181 template <template <class InnerNodeCRTP, class BaseKeyT> class Base,
182  class OuterNode, class KeyT_in, class ValueT_in, class AggValueT_in,
183  class Combiners, class Tag>
184 class InnerNode : public Base<InnerNode<Base, OuterNode, KeyT_in, ValueT_in,
185  AggValueT_in, Combiners, Tag>,
186  KeyT_in> {
187 public:
191  using KeyT = KeyT_in;
195  using ValueT = ValueT_in;
199  using AggValueT = AggValueT_in;
200 
207  KeyT get_point() const noexcept;
208 
214  bool is_start() const noexcept;
215 
221  bool is_end() const noexcept;
222 
229  bool is_closed() const noexcept;
230 
240  const OuterNode * get_interval() const noexcept;
241 
242  // TODO this must be reset when inserting into the tree!
243  size_t lca_tag = 0;
244 
245 private:
246  // TODO instead of storing all of these use interval traits and container
247  // pointer?
248  KeyT point;
249  bool start;
250  bool closed;
251 
252  // TODO remove this
253  OuterNode * container;
254 
255  AggValueT agg_left;
256  AggValueT agg_right;
257 
258  Combiners combiners;
259 
260  // The tree and the node traits have full access to the nodes
261  template <class FNode, class FNodeTraits, class FCombiners, class FOptions,
262  class TreeSelector, class FTag>
263  friend class ::ygg::DynamicSegmentTree;
264  template <class FInnerTree, class FInnerNode, class FNode, class FNodeTraits>
265  friend class InnerRBNodeTraits;
266  template <class FInnerTree, class FInnerNode, class FNode, class FNodeTraits>
267  friend class InnerWBNodeTraits;
268  template <class FInnerTree, class FInnerNode, class FAggValueT>
269  friend class InnerZNodeTraits;
270 
271  // Also, debugging classes are friends
272  template <class FInnerNode, class... FCombiners>
273  friend class ASCIIInnerNodeNameGetter;
274  template <class FInnerNode, class... FCombiners>
275  friend class DOTInnerNodeNameGette;
276 };
277 
279 
280 template <class InnerTree, class InnerNode, class AggValueT>
281 class InnerZNodeTraits { // TODO inherit from default traits?
282 public:
283  /*
284  * Data for Zipping
285  */
286  AggValueT left_accumulated;
287  AggValueT right_accumulated;
288 
289  /*
290  * Callbacks for Zipping
291  */
292  void init_zipping(const InnerNode * to_be_deleted) noexcept;
293  void before_zip_from_left(InnerNode * left_head) noexcept;
294  void before_zip_from_right(InnerNode * right_head) noexcept;
295  void before_zip_tree_from_left(InnerNode * left_head) const noexcept;
296  void before_zip_tree_from_right(InnerNode * right_head) const noexcept;
297  void zipping_ended_left_without_tree(InnerNode * prev_left_head) const
298  noexcept;
299  void zipping_ended_right_without_tree(InnerNode * prev_right_head) const
300  noexcept;
301  void zipping_done(InnerNode * head, InnerNode * tail) const noexcept;
302  void delete_without_zipping(const InnerNode * to_be_deleted) const noexcept;
303 
304  /*
305  * Data for Unzipping
306  */
307  InnerNode * unzip_left_last;
308  InnerNode * unzip_right_last;
309  bool unzip_left_first;
310  bool unzip_right_first;
311 
312  void init_unzipping(InnerNode * to_be_inserted) noexcept;
313  void unzip_to_left(InnerNode * n) noexcept;
314  void unzip_to_right(InnerNode * n) noexcept;
315  void unzip_done(InnerNode * unzip_root, InnerNode * left_spine_end,
316  InnerNode * right_spine_end) noexcept;
317 };
318 
319 template <class InnerTree, class InnerNode, class Node, class NodeTraits>
320 class InnerRBNodeTraits : public RBDefaultNodeTraits {
321 public:
322  template <class RBTreeBase>
323  static void leaf_inserted(const InnerNode & node,
324  const RBTreeBase & t) noexcept;
325  template <class RBTreeBase>
326  static void rotated_left(InnerNode & node, const RBTreeBase & t) noexcept;
327  template <class RBTreeBase>
328  static void rotated_right(InnerNode & node, const RBTreeBase & t) noexcept;
329  template <class RBTreeBase>
330  static void delete_leaf(const InnerNode & node,
331  const RBTreeBase & t) noexcept;
332  template <class RBTreeBase>
333  static void swapped(InnerNode & n1, InnerNode & n2, RBTreeBase & t) noexcept;
334 
335 private:
336  static InnerNode * get_partner(const InnerNode & n) noexcept;
337 };
338 
339 /*
340  * Since weight-balanced trees are based on the very same rotations that
341  * red-black trees are, we can use the exact same traits.
342  */
343 template <class InnerTree, class InnerNode, class Node, class NodeTraits>
344 class InnerWBNodeTraits
345  : public InnerRBNodeTraits<InnerTree, InnerNode, Node, NodeTraits> {
346 public:
347  template <class WBTreeBase>
348  static void splice_out_left_knee(
349  InnerNode & node,
350  const WBTreeBase & t) noexcept; // TODO if aggregate-addition is noexcept
351  template <class WBTreeBase>
352  static void
353  splice_out_right_knee(InnerNode & node,
354  const WBTreeBase & t) noexcept; // TODO see above
355 };
356 
357 template <class InnerNode>
358 class Compare {
359 public:
360  using PointDescription =
361  std::pair<const typename InnerNode::KeyT, const int_fast8_t>;
362 
363  bool operator()(const InnerNode & lhs, const InnerNode & rhs) const noexcept;
364  bool operator()(const typename InnerNode::KeyT & lhs,
365  const InnerNode & rhs) const noexcept;
366  bool operator()(const InnerNode & lhs,
367  const typename InnerNode::KeyT & rhs) const noexcept;
368  bool operator()(const PointDescription & lhs, const InnerNode & rhs) const
369  noexcept;
370  bool operator()(const InnerNode & lhs, const PointDescription & rhs) const
371  noexcept;
372 };
373 
374 /*
375  * Debugging helpers
376  */
377 template <class InnerNode, class... Combiners>
378 class ASCIIInnerNodeNameGetter {
379 public:
380  std::string get_name(InnerNode * node) const;
381 };
382 
383 template <class InnerNode, class... Combiners>
384 class DOTInnerNodeNameGetter {
385 public:
386  std::string get_name(InnerNode * node) const;
387 };
388 
389 template <class InnerNode>
390 class DOTInnerEdgeNameGetter {
391 public:
392  std::string get_name(InnerNode * node, bool left) const;
393 };
394 
396 } // namespace dyn_segtree_internal
397 
409 template <class... AdditionalOptions>
410 class UseRBTree : public dyn_segtree_internal::UseRBTree<AdditionalOptions...> {
411 };
413 
425 template <class... AdditionalOptions>
427  : public dyn_segtree_internal::UseZipTree<AdditionalOptions...> {
428 };
430 
442 template <class... AdditionalOptions>
443 class UseWBTree : public dyn_segtree_internal::UseWBTree<AdditionalOptions...> {
444 };
446 
457 template <class KeyType, class ValueType>
458 class MaxCombiner {
459 public:
460  using ValueT = ValueType;
461  using KeyT = KeyType;
463 
464  // TODO the bool is only returned for sake of expansion! Fix that!
484  bool collect_left(const KeyT my_point, const MyType * left_child_combiner,
485  const ValueType edge_val);
505  // TODO make all keys / values references?
506  bool collect_right(const KeyT my_point, const MyType * right_child_combiner,
507  const ValueType edge_val);
508 
509  // TODO the bool is only returned for sake of expansion! Fix that!
522  bool traverse_left_edge_up(const KeyT new_point, const ValueT edge_val);
535  bool traverse_right_edge_up(const KeyT new_point, const ValueT edge_val);
536 
537  // bool aggregate_with(ValueT a);
538 
559  bool rebuild(KeyT my_point, const MyType * left_child_combiner,
560  ValueT left_edge_val, const MyType * right_child_combiner,
561  ValueT right_edge_val);
562 
568  ValueT get() const noexcept;
569 
570  // TODO DEBUG
571  static std::string
572  get_name()
573  {
574  return "MaxCombiner";
575  }
576  // TODO DEBUG
577  std::string
578  get_dbg_value() const
579  {
580  return std::to_string(this->val);
581  }
582 
583 private:
584  ValueT val;
585 
586  ValueT child_value(const MyType * child) const noexcept;
587 };
588 
601 template <class KeyType, class ValueType>
603 public:
604  using ValueT = ValueType;
605  using KeyT = KeyType;
607 
609 
610  // TODO the bool is only returned for sake of expansion! Fix that!
631  bool collect_left(KeyT my_point, const MyType * left_child_combiner,
632  ValueType edge_val);
653  bool collect_right(KeyT my_point, const MyType * right_child_combiner,
654  ValueType edge_val);
655 
656  // TODO the bool is only returned for sake of expansion! Fix that!
669  bool traverse_left_edge_up(KeyT new_point, ValueT edge_val);
682  bool traverse_right_edge_up(KeyT new_point, ValueT edge_val);
683 
684  // bool aggregate_with(ValueT a);
685 
706  bool rebuild(KeyT my_point, const MyType * left_child_combiner,
707  ValueT left_edge_val, const MyType * right_child_combiner,
708  ValueT right_edge_val);
709 
715  ValueT get() const noexcept;
716 
730  bool is_left_border_valid() const noexcept;
744  bool is_right_border_valid() const noexcept;
745 
755  KeyT get_left_border() const noexcept;
756 
766  KeyT get_right_border() const noexcept;
767 
768  // TODO DEBUG
769  static std::string
770  get_name()
771  {
772  return "RangedMaxCombiner";
773  }
774  // TODO DEBUG
775  std::string
776  get_dbg_value() const
777  {
778  std::string res = std::to_string(this->val) + std::string("@[");
779  if (this->left_border_valid) {
780  res += std::to_string(this->left_border);
781  } else {
782  res += std::string("--");
783  }
784  res += ":";
785  if (this->right_border_valid) {
786  res += std::to_string(this->right_border);
787  } else {
788  res += "--";
789  }
790  res += "]";
791 
792  return res;
793  }
794 
795 private:
796  ValueT val;
797 
798  // TODO replace by std::optional when switching to C++17
799  KeyT left_border;
800  bool left_border_valid;
801  KeyT right_border;
802  bool right_border_valid;
803 
804  ValueT child_value(const MyType * child) const noexcept;
805 };
806 
821 template <class KeyT, class AggValueT, class... Combiners>
823 public:
824  using MyType = CombinerPack<KeyT, AggValueT, Combiners...>;
825 
826  CombinerPack() = default;
827 
844  bool rebuild(KeyT my_point, const MyType * left_child,
845  AggValueT left_edge_val, const MyType * right_child,
846  AggValueT right_edge_val);
847 
848  // TODO the bool is only returned for sake of expansion! Fix that!
849  bool collect_left(KeyT my_point, const MyType * left_child_combiner,
850  AggValueT edge_val);
851  bool collect_right(KeyT my_point, const MyType * right_child_combiner,
852  AggValueT edge_val);
853 
854  // TODO the bool is only returned for sake of expansion! Fix that!
855  bool traverse_left_edge_up(KeyT new_point, AggValueT edge_val);
856  bool traverse_right_edge_up(KeyT new_point, AggValueT edge_val);
857 
867  template <class Combiner>
868  typename Combiner::ValueT get() const;
869 
876  template <class Combiner>
877  const Combiner & get_combiner() const;
878 
879  using pack = std::tuple<Combiners...>;
880 
881 private:
882  template <class Combiner>
883  const Combiner * child_combiner(const MyType * child) const;
884 
885  std::tuple<Combiners...> data;
886 };
887 
888 template <class KeyT, class AggValueT>
890 
912 template <class KeyType, class ValueType, class AggValueType, class Combiners,
913  class TreeSelector = UseDefaultRBTree, class Tag = int>
915  // TODO why is all of this public?
916 public:
918  using KeyT = KeyType;
919  using ValueT = ValueType;
920  using AggValueT = AggValueType;
921  using MyClass = DynSegTreeNodeBase<KeyType, ValueType, AggValueType,
922  Combiners, TreeSelector, Tag>;
923 
924  using InnerNode = dyn_segtree_internal::InnerNode<
925  TreeSelector::template InnerNodeBaseBuilder<
926  typename TreeSelector::template Tag<Tag>>::template Base,
927  MyClass, KeyT, ValueT, AggValueT, Combiners, Tag>;
928 
929  // TODO make these private
934  InnerNode start;
935 
940  InnerNode end;
942 };
943 
956 template <class Node> // TODO move this into the methods
958 public:
962  using KeyT = typename Node::KeyT;
967  using ValueT = typename Node::ValueT;
968 
976  static KeyT get_lower(const Node & n);
977 
985  static KeyT get_upper(const Node & n);
986 
993  static bool
994  is_lower_closed(const Node & n)
995  {
996  (void)n;
997  return true;
998  };
999 
1006  static bool
1007  is_upper_closed(const Node & n)
1008  {
1009  (void)n;
1010  return false;
1011  };
1012 
1020  static ValueT get_value(const Node & n);
1021 };
1022 
1062 // TODO DOC right-open intervals
1063 
1064 // TODO constant-time size
1065 template <class Node, class NodeTraits, class Combiners,
1066  class Options = DefaultOptions, class TreeSelector = UseDefaultRBTree,
1067  class Tag = int>
1068 class DynamicSegmentTree {
1069  // TODO add a static assert that checks that the types in all combiners are
1070  // right
1071 private:
1072  using NB = DynSegTreeNodeBase<typename Node::KeyT, typename Node::ValueT,
1073  typename Node::AggValueT, Combiners,
1074  TreeSelector, Tag>;
1075  using InnerNode = typename NB::InnerNode;
1076 
1077  static_assert(std::is_base_of<DynSegTreeNodeTraits<Node>, NodeTraits>::value,
1078  "NodeTraits not properly derived from DynSegTreeNodeTraits!");
1079  static_assert(std::is_base_of<NB, Node>::value,
1080  "Node class not properly derived from DynSegTreeNodeBase!");
1081  static_assert(Options::multiple,
1082  "DynamicSegmentTree always allows multiple equal intervals.");
1083 
1084 public:
1085  using KeyT = typename Node::KeyT;
1086  using ValueT = typename Node::ValueT;
1087  using AggValueT = typename Node::AggValueT;
1088  using MyClass = DynamicSegmentTree<Node, NodeTraits, Combiners, Options,
1089  TreeSelector, Tag>;
1090 
1091 private:
1092  class InnerTree
1093  : public TreeSelector::template BaseTree<InnerTree, Node, NodeTraits,
1094  InnerNode, Tag> {
1095  public:
1096  using BaseTree =
1097  typename TreeSelector::template BaseTree<InnerTree, Node, NodeTraits,
1098  InnerNode, Tag>;
1099 
1100  using BaseTree::BaseTree;
1101 
1102  void modify_contour(InnerNode * left, InnerNode * right, ValueT val);
1103 
1104  using Contour =
1105  std::pair<std::vector<InnerNode *>, std::vector<InnerNode *>>;
1106  void build_lca(InnerNode * left, InnerNode * right) const;
1107 
1108  static bool rebuild_combiners_at(InnerNode * n);
1109  static void rebuild_combiners_recursively(InnerNode * n);
1110 
1111  private:
1112  // Generation to be used to tag nodes during LCA search
1113  mutable size_t generation = 0;
1114  // Allocate-once buffers for the contour
1115 
1116  // TODO this is real bad style: public mutable members?
1117  public:
1126  mutable std::vector<InnerNode *> contour_left_path;
1135  mutable std::vector<InnerNode *> contour_right_path;
1136  };
1137 
1138 public:
1142  DynamicSegmentTree(MyClass && other);
1143 
1148 
1157  void insert(Node & n);
1158 
1166  void remove(Node & n);
1167 
1175  bool empty() const;
1176 
1186  AggValueT query(const typename Node::KeyT & x) const noexcept;
1187 
1188  template <class Combiner>
1189  Combiner get_combiner() const;
1190 
1191  template <class Combiner>
1192  Combiner get_combiner(const typename Node::KeyT & lower,
1193  const typename Node::KeyT & upper,
1194  bool lower_closed = true,
1195  bool upper_closed = false) const;
1196 
1197  template <class Combiner>
1198  typename Combiner::ValueT get_combined() const;
1199 
1200  template <class Combiner>
1201  typename Combiner::ValueT get_combined(const typename Node::KeyT & lower,
1202  const typename Node::KeyT & upper,
1203  bool lower_closed = true,
1204  bool upper_closed = false) const;
1205 
1206  /*
1207  * Iteration
1208  */
1209  template <bool reverse>
1210  using const_iterator = typename InnerTree::template const_iterator<reverse>;
1211  template <bool reverse>
1212  using iterator = typename InnerTree::template iterator<reverse>;
1213 
1214  // TODO derive a non-internal class from the InnerNode, and make the iterator
1215  // return a pointer to that.
1216 
1222  const_iterator<false> cbegin() const;
1228  const_iterator<false> cend() const;
1234  const_iterator<false> begin() const;
1235  iterator<false> begin();
1236 
1242  const_iterator<false> end() const;
1243  iterator<false> end();
1244 
1250  const_iterator<true> crbegin() const;
1256  const_iterator<true> crend() const;
1262  const_iterator<true> rbegin() const;
1263  iterator<true> rbegin();
1264 
1270  const_iterator<true> rend() const;
1271  iterator<true> rend();
1272 
1281  const_iterator<false>
1282  lower_bound_event(const typename Node::KeyT & key) const;
1283  iterator<false> lower_bound_event(const typename Node::KeyT & key);
1284 
1293  const_iterator<false>
1294  upper_bound_event(const typename Node::KeyT & key) const;
1295  iterator<false> upper_bound_event(const typename Node::KeyT & key);
1296 
1304  void clear();
1305 
1306  /*
1307  * DEBUGGING
1308  */
1309  void dbg_verify() const;
1310 
1311  template <class Combiner>
1312  void dbg_verify_max_combiner() const;
1313 
1314 private:
1315  // TODO build a generic function for this
1316  template <class... Ts>
1317  using NodeNameGetterCurried =
1318  dyn_segtree_internal::ASCIIInnerNodeNameGetter<InnerNode, Ts...>;
1319  using NodeNameGetter =
1320  typename utilities::pass_pack<typename Combiners::pack,
1321  NodeNameGetterCurried>::type;
1322  template <class... Ts>
1323  using DotNameGetterCurried =
1324  dyn_segtree_internal::DOTInnerNodeNameGetter<InnerNode, Ts...>;
1325  using DotNameGetter =
1326  typename utilities::pass_pack<typename Combiners::pack,
1327  DotNameGetterCurried>::type;
1328 
1329  using TreePrinter = debug::TreePrinter<InnerNode, NodeNameGetter>;
1330  using TreeDotExporter = debug::TreeDotExport<
1331  InnerNode, DotNameGetter,
1332  dyn_segtree_internal::DOTInnerEdgeNameGetter<InnerNode>>;
1333 
1334 public:
1335  // TODO Debugging only!
1336  void dbg_print_inner_tree() const;
1337  std::stringstream & dbg_get_dot() const;
1338 
1339 private:
1340  void apply_interval(Node & n);
1341  void unapply_interval(Node & n);
1342 
1343  InnerTree t;
1344 
1345  void dbg_verify_all_points() const;
1346  void dbg_verify_start_end() const;
1347 };
1348 
1349 } // namespace ygg
1350 
1351 #ifndef YGG_DYNAMIC_SEGMENT_TREE_CPP
1352 #include "dynamic_segment_tree.cpp"
1353 #endif
1354 
1355 #endif // YGG_DYNAMIC_SEGMENT_TREE_HPP
typename Node::ValueT ValueT
Definition: dynamic_segment_tree.hpp:967
A combiner that allows to retrieve the maximum value over any range.
Definition: dynamic_segment_tree.hpp:458
Base class (template) to supply your node class with metainformation.
Definition: wbtree.hpp:36
static bool is_lower_closed(const Node &n)
Definition: dynamic_segment_tree.hpp:994
Representation of either a start or an end of an interval.
Definition: dynamic_segment_tree.hpp:184
static bool is_upper_closed(const Node &n)
Definition: dynamic_segment_tree.hpp:1007
The Zip Tree.
Definition: ziptree.hpp:194
A combiner that allows to retrieve the maximum value over any range plus the range over which the max...
Definition: dynamic_segment_tree.hpp:602
Helper base class for the NodeTraits you need to implement.
Definition: rbtree.hpp:120
The Weight Balanced Tree.
Definition: wbtree.hpp:142
Base class (template) to supply your node class with metainformation.
Definition: rbtree.hpp:92
AggValueT_in AggValueT
The type of the aggregate value.
Definition: dynamic_segment_tree.hpp:199
typename Node::KeyT KeyT
Definition: dynamic_segment_tree.hpp:962
Definition: dynamic_segment_tree.hpp:28
KeyT_in KeyT
The type of the key (i.e., the interval bounds)
Definition: dynamic_segment_tree.hpp:191
Base class (template) to supply your node class with metainformation.
Definition: dynamic_segment_tree.hpp:914
The Red-Black Tree.
Definition: rbtree.hpp:194
Class used to select the weight balanced tree as underlying tree for the DynamicSegmentTree.
Definition: dynamic_segment_tree.hpp:443
Class used to select the red-black tree as underlying tree for the DynamicSegmentTree.
Definition: dynamic_segment_tree.hpp:410
This class represents the pack of combiners associated with every node of a Dynamic Segment Tree...
Definition: dynamic_segment_tree.hpp:822
Base class (template) to supply your node class with metainformation.
Definition: ziptree.hpp:21
You must derive your own traits class from this class template, telling the DynamicSegmentTree how to...
Definition: dynamic_segment_tree.hpp:957
The Dynamic Segment Tree class.
Definition: dynamic_segment_tree.hpp:21
ValueT_in ValueT
The type of the value associated with the intervals.
Definition: dynamic_segment_tree.hpp:195
KeyT get_point() const noexcept
Returns the point at which the event represented by this InnerNode happens.
Class used to select the Zip Tree tree as underlying tree for the DynamicSegmentTree.
Definition: dynamic_segment_tree.hpp:426
Definition: rbtree.hpp:18