|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Augmented treap storing intervals with overlap/stabbing queries. More...
#include <tpl_interval_tree.H>
Classes | |
| struct | Iterator |
| Inorder iterator over nodes. More... | |
| struct | Step |
| A step of the way down from the root: a node, and the side taken there. More... | |
Public Types | |
| using | Key = Interval< T > |
| using | IntervalCmp = Interval_Less< T, Compare > |
| using | Node = NodeType< Key > |
Public Member Functions | |
| void | set_seed (const unsigned long seed) |
Seeds the Mersenne Twister of the tree, as gsl_rng_set() did: the priorities are from then on those of GSL for the seed. | |
| IntervalCmp | key_comp () const noexcept(std::is_nothrow_copy_constructible_v< Compare >) |
| Return the interval comparison functor (over Interval<T> keys). | |
| const Compare & | endpoint_comp () const noexcept |
| Return the endpoint comparison functor (const) | |
| const Compare & | get_compare () const noexcept |
| Backwards-compatible accessor for the endpoint comparator. | |
| void | swap (Gen_Interval_Tree &tree) noexcept(noexcept(std::swap(tree_root, tree.tree_root)) and noexcept(std::swap(cmp, tree.cmp)) and noexcept(r.swap(tree.r)) and noexcept(std::swap(num_nodes, tree.num_nodes))) |
Swap all state with tree in O(1) | |
| Gen_Interval_Tree (const unsigned long seed, const Compare &_cmp=Compare()) | |
| Construct with explicit seed and comparator: the priorities are those of GSL for the seed, drawn from a Mersenne Twister in dynamic memory. | |
| Gen_Interval_Tree (const Compare &_cmp=Compare()) | |
| Construct without a seed: the priorities are drawn from a SplitMix64 with a seed of its own, inside the tree, which allocates nothing. | |
| Gen_Interval_Tree (const Gen_Interval_Tree &)=delete | |
| Deleted copy constructor. | |
| Gen_Interval_Tree & | operator= (const Gen_Interval_Tree &)=delete |
| Deleted copy assignment. | |
| Gen_Interval_Tree (Gen_Interval_Tree &&)=delete | |
| Deleted move constructor. | |
| Gen_Interval_Tree & | operator= (Gen_Interval_Tree &&)=delete |
| Deleted move assignment. | |
| Random_Source & | random_source () noexcept |
| The source of random numbers, which gives the priorities. | |
| const Random_Source & | random_source () const noexcept |
| The source of random numbers, to look at it: its engine, or whether it is equal to another one. | |
| Gsl_Compatible_Rng & | rng () const |
| The Mersenne Twister of the tree, which a tree that was given no seed makes here, and draws from it from then on. | |
| Node *& | getRoot () noexcept |
| Return the tree's root. | |
| const Node * | getRoot () const |
| Return the tree's root (const) | |
| size_t | size () const noexcept |
| Return the number of nodes. | |
| bool | is_empty () const noexcept |
| Return true if the tree is empty. | |
| void | reset_num_nodes () noexcept |
| Reset the node count (used after manual tree destruction) | |
| const Node * | search (const Key &key) const noexcept(std::is_nothrow_copy_constructible_v< Compare > and NothrowPredicateWith< const Compare &, const T &, const T & >) |
| Search for an exact interval in the tree. | |
| Node * | insert (Node *p) |
| Insert a node (no duplicates). | |
| Node * | insert_dup (Node *p) |
| Insert a node (duplicates allowed). | |
| Node * | remove (const Key &key) |
| Remove an interval from the tree. | |
| const Node * | overlap_search (const Key &query) const |
Find any interval that overlaps with query (CLRS algorithm). | |
| template<class Op > | |
| void | all_overlaps (const Key &query, Op &&op) const |
Apply op to every interval overlapping query. | |
| DynList< Key > | find_all_overlaps (const Key &query) const |
Find all intervals overlapping query. | |
| template<class Op > | |
| void | stab (const T &p, Op &&op) const |
Apply op to every interval containing point p. | |
| DynList< Key > | find_stab (const T &p) const |
Find all intervals containing point p. | |
| bool | verify () const |
| Verify BST, heap, and max_endpoint invariants. | |
Private Types | |
| using | Pending = interval_tree_detail::Pending_Max< T > |
Private Member Functions | |
| Node *& | link_from (Step *step) noexcept |
| The link that hangs from a step: that of the root if there is none. | |
| void | place (Node *p, Step *bottom) |
| Put a node in its place, at the end of the way down. | |
| Node * | insert (Node *root, Node *p, Step *up) |
Go down to the place of p and put it there, unless its interval is in the tree, which then gives Node::NullPtr and does not change. | |
| void | insert_dup (Node *root, Node *p, Step *up) |
Go down to the place of p and put it there, after the intervals that are the same as its own. | |
| Node * | join (Node *t1, Node *t2, Step *up, const Step *whole, Step *spine) |
| Join two trees, every interval of the first one before those of the second one. | |
| void | unlink (Node *p, Step *up) |
| Take a node out of the tree: its two subtrees, joined, take its place. | |
| Node * | remove (Node *root, const Key &key, Step *up) |
Go down to the node of the interval key and take it out of the tree. | |
Static Private Member Functions | |
| static unsigned long | generator_seed (const unsigned long seed) noexcept |
| static bool | goes_before (const Key &a, const Key &b, const Compare &cmp) |
True if a goes before b: by its low endpoint, then by its high one. | |
| static int | side_of (const Key &a, const Key &b, const Compare &cmp) |
The side of b where a goes: -1 before it, 1 after it, and 0 if they are the same interval. | |
| template<class Op > | |
| static void | all_overlaps (Node *root, const Key &query, Op &op, const Compare &cmp) |
| Recursive: find all intervals overlapping query. | |
| static bool | check_max (Node *root, const Compare &cmp) |
| Verify max_endpoint invariant. | |
| static size_t | count_nodes (Node *root) noexcept |
Private Attributes | |
| Node | head |
| Node * | head_ptr |
| Node *& | tree_root |
| Random_Source | r |
| Compare | cmp |
| size_t | num_nodes |
Augmented treap storing intervals with overlap/stabbing queries.
Gen_Interval_Tree is a standalone augmented treap that stores Interval<T> values and maintains a max_endpoint field in each node for efficient interval query pruning.
This is a low-level class managing raw node pointers. For automatic memory management, use DynIntervalTree.
| NodeType | Node template (Interval_Tree_Node or Interval_Tree_NodeVtl). |
| T | Endpoint type. |
| Compare | Comparison functor for endpoints. |
Definition at line 604 of file tpl_interval_tree.H.
| using Aleph::Gen_Interval_Tree< NodeType, T, Compare >::IntervalCmp = Interval_Less<T, Compare> |
Definition at line 608 of file tpl_interval_tree.H.
| using Aleph::Gen_Interval_Tree< NodeType, T, Compare >::Key = Interval<T> |
Definition at line 607 of file tpl_interval_tree.H.
| using Aleph::Gen_Interval_Tree< NodeType, T, Compare >::Node = NodeType<Key> |
Definition at line 609 of file tpl_interval_tree.H.
|
private |
Definition at line 627 of file tpl_interval_tree.H.
|
inline |
Construct with explicit seed and comparator: the priorities are those of GSL for the seed, drawn from a Mersenne Twister in dynamic memory.
| [in] | seed | Random seed, taken through an unsigned int, modulo 2^32 - 1, as it was for GSL. |
| [in] | _cmp | Comparison functor. |
| std::bad_alloc | if the Mersenne Twister cannot be allocated. |
Definition at line 1006 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::head_ptr, Aleph::Min_Priority, and Aleph::PRIO().
|
inline |
Construct without a seed: the priorities are drawn from a SplitMix64 with a seed of its own, inside the tree, which allocates nothing.
| [in] | _cmp | Comparison functor. |
Definition at line 1020 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::head_ptr, Aleph::Min_Priority, and Aleph::PRIO().
|
delete |
Deleted copy constructor.
|
delete |
Deleted move constructor.
|
inline |
Apply op to every interval overlapping query.
| query | the query interval |
| op | callable with signature void(const Interval<T>&) |
Definition at line 1202 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::all_overlaps(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::cmp, and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::tree_root.
|
inlinestaticprivate |
Recursive: find all intervals overlapping query.
Definition at line 903 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::all_overlaps(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::cmp, Aleph::Interval< T >::high, KEY, LLINK, Aleph::low(), Aleph::Interval< T >::low, Aleph::MAX_EP(), RLINK, and root().
Referenced by Aleph::Gen_Interval_Tree< NodeType, T, Compare >::all_overlaps(), Aleph::DynIntervalTree< T, Compare >::all_overlaps(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::all_overlaps(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::find_all_overlaps(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::stab().
|
inlinestaticprivate |
Verify max_endpoint invariant.
Definition at line 929 of file tpl_interval_tree.H.
References Aleph::and, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::check_max(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::cmp, KEY, LLINK, Aleph::MAX_EP(), RLINK, and root().
Referenced by Aleph::Gen_Interval_Tree< NodeType, T, Compare >::check_max(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::verify().
|
inlinestaticprivatenoexcept |
Definition at line 948 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::count_nodes(), LLINK, RLINK, and root().
Referenced by Aleph::Gen_Interval_Tree< NodeType, T, Compare >::count_nodes(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::verify().
|
inlinenoexcept |
Return the endpoint comparison functor (const)
Definition at line 979 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::cmp.
Referenced by Aleph::DynIntervalTree< T, Compare >::DynIntervalTree(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::get_compare(), Aleph::DynIntervalTree< T, Compare >::insert(), Aleph::DynIntervalTree< T, Compare >::insert(), and Aleph::DynIntervalTree< T, Compare >::insert_dup().
|
inline |
Find all intervals overlapping query.
| query | the query interval |
Definition at line 1212 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::all_overlaps(), and Aleph::DynList< T >::append().
Referenced by Aleph::DynIntervalTree< T, Compare >::find_all_overlaps(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::find_stab().
|
inline |
Find all intervals containing point p.
| p | the query point |
Definition at line 1239 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::find_all_overlaps(), and Aleph::Interval< T >::point().
Referenced by Aleph::DynIntervalTree< T, Compare >::find_stab().
|
inlinestaticprivatenoexcept |
Definition at line 621 of file tpl_interval_tree.H.
References Aleph::Gsl_Compatible_Rng::max(), and seed.
|
inlinenoexcept |
Backwards-compatible accessor for the endpoint comparator.
Definition at line 982 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::endpoint_comp().
|
inline |
Return the tree's root (const)
Definition at line 1075 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::tree_root.
|
inlinenoexcept |
Return the tree's root.
Definition at line 1072 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::tree_root.
Referenced by Aleph::DynIntervalTree< T, Compare >::destroy_tree(), IntervalTreeRawTest::TearDown(), TEST(), Aleph::DynIntervalTree< T, Compare >::traverse(), and Aleph::DynIntervalTree< T, Compare >::traverse().
|
inlinestaticprivate |
True if a goes before b: by its low endpoint, then by its high one.
It is Interval_Less, without a copy of the comparator.
Definition at line 648 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::cmp, Aleph::Interval< T >::high, and Aleph::Interval< T >::low.
Referenced by Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert_dup().
|
inline |
Insert a node (no duplicates).
| p | pointer to the node to insert |
| what | the comparison or the copy of an endpoint throw, with the tree as it was and p out of it. |
p is out of the tree, but the maxima of some nodes may be left changed: the queries may miss intervals, and neither an insertion nor a removal repairs them. Such a tree must be destroyed, or built again from its intervals. Definition at line 1116 of file tpl_interval_tree.H.
References Aleph::Random_Source::get(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert(), KEY, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::num_nodes, Aleph::PRIO(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::r, and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::tree_root.
|
inlineprivate |
Go down to the place of p and put it there, unless its interval is in the tree, which then gives Node::NullPtr and does not change.
Definition at line 752 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::cmp, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert(), KEY, LLINK, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::place(), RLINK, root(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::side_of().
Referenced by Aleph::DynIntervalTree< T, Compare >::insert(), Aleph::DynIntervalTree< T, Compare >::insert(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert().
|
inline |
Insert a node (duplicates allowed).
| p | pointer to the node to insert |
| what | the comparison or the copy of an endpoint throw, with the tree as it was and p out of it. |
Definition at line 1136 of file tpl_interval_tree.H.
References Aleph::Random_Source::get(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert_dup(), KEY, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::num_nodes, Aleph::PRIO(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::r, and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::tree_root.
|
inlineprivate |
Go down to the place of p and put it there, after the intervals that are the same as its own.
Definition at line 769 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::cmp, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::goes_before(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert_dup(), KEY, LLINK, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::place(), RLINK, and root().
Referenced by Aleph::DynIntervalTree< T, Compare >::insert_dup(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert_dup(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert_dup().
|
inlinenoexcept |
Return true if the tree is empty.
Definition at line 1081 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::num_nodes.
Referenced by Aleph::DynIntervalTree< T, Compare >::is_empty().
|
inlineprivate |
Join two trees, every interval of the first one before those of the second one.
It is the end of a removal. The comparisons are made on the way down, with the trees as they were. At the bottom, the removed node, those above it and those of the two inner spines take their new maxima; and on the way back each node of the spines takes its link.
| [in,out] | t1 | the first tree. |
| [in,out] | t2 | the second tree. |
| [in,out] | up | the step of the removed node, with those of the nodes above it. |
| [in] | whole | the first step, from up, whose maximum stays. |
| [in,out] | spine | the nodes of the spines above these two trees, as steps, from the last one. |
| what | the comparison or the copy of an endpoint throw, with the trees as they were. |
Definition at line 800 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::cmp, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::join(), LLINK, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::Step::max, Aleph::MAX_EP(), Aleph::PRIO(), RLINK, Aleph::interval_tree_detail::Pending_Max< T, bool >::set(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::Step::up.
Referenced by Aleph::Gen_Interval_Tree< NodeType, T, Compare >::join(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::unlink().
|
inlinenoexcept |
Return the interval comparison functor (over Interval<T> keys).
It holds a copy of the endpoint comparator, so it throws what copying that comparator throws.
Definition at line 973 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::cmp.
Referenced by Aleph::DynIntervalTree< T, Compare >::key_comp(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::search(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::verify().
|
inlineprivatenoexcept |
The link that hangs from a step: that of the root if there is none.
Definition at line 639 of file tpl_interval_tree.H.
References LLINK, RLINK, and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::tree_root.
Referenced by Aleph::Gen_Interval_Tree< NodeType, T, Compare >::place(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::unlink().
|
delete |
Deleted copy assignment.
|
delete |
Deleted move assignment.
|
inline |
Find any interval that overlaps with query (CLRS algorithm).
| query | the query interval |
Definition at line 1177 of file tpl_interval_tree.H.
References Aleph::and, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::cmp, KEY, LLINK, Aleph::Interval< T >::low, Aleph::MAX_EP(), RLINK, and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::tree_root.
Referenced by Aleph::DynIntervalTree< T, Compare >::overlap_search().
|
inlineprivate |
Put a node in its place, at the end of the way down.
The tree that it leaves is the one that the rotations of a treap give. Every comparison, and every copy of an endpoint that may throw, comes before the tree changes: if one throws, the tree is as it was, and p is not in it.
| [in,out] | p | the node, with its priority and its maximum, the high endpoint of its interval. |
| [in,out] | bottom | the last step of the way, whose link p would hang from as a leaf; nullptr in an empty tree. |
| what | the comparison or the copy of an endpoint throw. |
Definition at line 683 of file tpl_interval_tree.H.
References Aleph::and, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::cmp, Aleph::interval_tree_detail::Pending_Max< T, bool >::give(), KEY, l, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::Step::left, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::link_from(), LLINK, max(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::Step::max, Aleph::MAX_EP(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::Step::node, Aleph::PRIO(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::r, RLINK, Aleph::interval_tree_detail::Pending_Max< T, bool >::set(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::Step::up.
Referenced by Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert_dup().
|
inlinenoexcept |
The source of random numbers, to look at it: its engine, or whether it is equal to another one.
Definition at line 1040 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::r.
|
inlinenoexcept |
The source of random numbers, which gives the priorities.
Definition at line 1036 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::r.
Referenced by TEST().
|
inline |
Remove an interval from the tree.
| key | the interval to remove |
| what | the comparison or the copy of an endpoint throw, with the tree as it was. |
Definition at line 1161 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::num_nodes, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::remove(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::tree_root.
|
inlineprivate |
Go down to the node of the interval key and take it out of the tree.
It gives the node, or Node::NullPtr if the tree has none.
Definition at line 886 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::cmp, KEY, LLINK, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::remove(), RLINK, root(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::side_of(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::unlink().
Referenced by Aleph::DynIntervalTree< T, Compare >::remove(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::remove(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::remove().
|
inlinenoexcept |
Reset the node count (used after manual tree destruction)
Definition at line 1084 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::num_nodes.
Referenced by Aleph::DynIntervalTree< T, Compare >::destroy_tree().
|
inline |
The Mersenne Twister of the tree, which a tree that was given no seed makes here, and draws from it from then on.
| std::bad_alloc | If the tree has no Mersenne Twister and there is not enough memory for it. |
Definition at line 1056 of file tpl_interval_tree.H.
References Aleph::Random_Source::mersenne_twister(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::r.
Referenced by TEST().
|
inlinenoexcept |
Search for an exact interval in the tree.
| key | the interval to search for |
| what | the comparison or its copy throw; nothing when neither does. |
Definition at line 1093 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::key_comp(), Aleph::searchInBinTree(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::tree_root.
Referenced by Aleph::DynIntervalTree< T, Compare >::search().
|
inline |
Seeds the Mersenne Twister of the tree, as gsl_rng_set() did: the priorities are from then on those of GSL for the seed.
A tree that was given no seed makes its Mersenne Twister here.
| [in] | seed | The seed. |
| std::bad_alloc | if the tree has no Mersenne Twister and there is not enough memory for it; then it is unchanged. |
Definition at line 965 of file tpl_interval_tree.H.
References Aleph::Random_Source::Mersenne_Twister, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::r, Aleph::Random_Source::seed(), and seed.
Referenced by IntervalTreeRawTest::SetUp().
|
inlinestaticprivate |
The side of b where a goes: -1 before it, 1 after it, and 0 if they are the same interval.
Definition at line 659 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::cmp, Aleph::Interval< T >::high, and Aleph::Interval< T >::low.
Referenced by Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::remove().
|
inlinenoexcept |
Return the number of nodes.
Definition at line 1078 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::num_nodes.
Referenced by Aleph::DynIntervalTree< T, Compare >::size().
|
inline |
Apply op to every interval containing point p.
| p | the query point |
| op | callable with signature void(const Interval<T>&) |
| May | throw if the provided callback throws. |
Definition at line 1228 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::all_overlaps(), and Aleph::Interval< T >::point().
Referenced by Aleph::DynIntervalTree< T, Compare >::stab().
|
inlinenoexcept |
Swap all state with tree in O(1)
Definition at line 985 of file tpl_interval_tree.H.
References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::cmp, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::num_nodes, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::r, Aleph::Random_Source::swap(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::tree_root.
Referenced by Aleph::DynIntervalTree< T, Compare >::DynIntervalTree(), Aleph::DynIntervalTree< T, Compare >::operator=(), and Aleph::DynIntervalTree< T, Compare >::swap().
|
inlineprivate |
Take a node out of the tree: its two subtrees, joined, take its place.
The node is left as its reset() leaves it.
Every comparison, and every copy of an endpoint that may throw, comes before the tree changes: if one throws, the tree is as it was.
| [in] | p | the node. |
| [in,out] | up | the step of its parent; nullptr if it is the root. |
| what | the comparison or the copy of an endpoint throw. |
Definition at line 840 of file tpl_interval_tree.H.
References Aleph::and, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::cmp, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::join(), KEY, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::Step::left, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::link_from(), LLINK, max(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::Step::max, Aleph::MAX_EP(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::Step::node, RLINK, Aleph::interval_tree_detail::Pending_Max< T, bool >::set(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::Step::up.
Referenced by Aleph::Gen_Interval_Tree< NodeType, T, Compare >::remove().
|
inline |
Verify BST, heap, and max_endpoint invariants.
Definition at line 1248 of file tpl_interval_tree.H.
References Aleph::check_bst(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::check_max(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::cmp, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::count_nodes(), Aleph::is_treap(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::key_comp(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::num_nodes, and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::tree_root.
Referenced by TEST(), and Aleph::DynIntervalTree< T, Compare >::verify().
|
private |
Definition at line 616 of file tpl_interval_tree.H.
Referenced by Aleph::Gen_Interval_Tree< NodeType, T, Compare >::all_overlaps(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::all_overlaps(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::check_max(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::endpoint_comp(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::goes_before(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert_dup(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::join(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::key_comp(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::overlap_search(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::place(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::remove(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::side_of(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::swap(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::unlink(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::verify().
|
private |
Definition at line 612 of file tpl_interval_tree.H.
|
private |
Definition at line 613 of file tpl_interval_tree.H.
Referenced by Aleph::Gen_Interval_Tree< NodeType, T, Compare >::Gen_Interval_Tree(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::Gen_Interval_Tree().
|
private |
Definition at line 617 of file tpl_interval_tree.H.
Referenced by Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert_dup(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::is_empty(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::remove(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::reset_num_nodes(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::size(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::swap(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::verify().
|
mutableprivate |
Definition at line 615 of file tpl_interval_tree.H.
Referenced by Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert_dup(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::place(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::random_source(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::random_source(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::rng(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::set_seed(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::swap().
|
private |
Definition at line 614 of file tpl_interval_tree.H.
Referenced by Aleph::Gen_Interval_Tree< NodeType, T, Compare >::all_overlaps(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::getRoot(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::getRoot(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert_dup(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::link_from(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::overlap_search(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::remove(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::search(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::swap(), and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::verify().