58# ifndef TPL_INTERVAL_TREE_H
59# define TPL_INTERVAL_TREE_H
66# include <type_traits>
100 noexcept(
std::is_nothrow_default_constructible_v<
T>)
109 noexcept(std::is_nothrow_copy_constructible_v<T>)
118 noexcept(std::is_nothrow_move_constructible_v<T>)
127 noexcept(std::is_nothrow_copy_constructible_v<T>)
139 template <
class Compare = Aleph::less<T>>
141 const Compare &
cmp = Compare()) const
145 return not
static_cast<bool>(
cmp(other.
high,
low))
156 template <
class Compare = Aleph::less<T>>
158 const Compare &
cmp = Compare()) const
161 return not
static_cast<bool>(
cmp(p,
low))
and not
static_cast<bool>(
cmp(
high, p));
170 template <
class Compare = Aleph::less<T>>
171 [[nodiscard]]
bool is_valid(
const Compare &
cmp = Compare()) const
184 noexcept(
noexcept(
static_cast<bool>(std::declval<const T &>() == std::declval<const T &>())))
186 return static_cast<bool>(
low == other.
low)
and static_cast<bool>(
high == other.
high);
195 noexcept(
noexcept(*
this == other))
197 return not (*
this == other);
207 template <
typename T,
class Compare = Aleph::less<T>>
217 noexcept(
std::is_nothrow_copy_constructible_v<Compare>)
229 if (
static_cast<bool>(
cmp(a.low, b.low)))
231 if (
static_cast<bool>(
cmp(b.low, a.low)))
233 return static_cast<bool>(
cmp(a.high, b.high));
240 template <
typename Key>
244 template <
typename T>
250 template <
typename Key>
261 template <
typename T>
269 noexcept(
std::is_nothrow_default_constructible_v<
T>)
273 noexcept(std::is_nothrow_default_constructible_v<T>)
295 template <
typename Key>
333 noexcept(std::is_nothrow_move_constructible_v<Key>
and
334 std::is_nothrow_default_constructible_v<Data>
and
335 std::is_nothrow_copy_assignable_v<Endpoint>)
349 noexcept(std::is_nothrow_move_constructible_v<Key>
and
350 std::is_nothrow_move_constructible_v<Data>)
385 template <
typename Key>
388 template <
typename Key>
396 template <
typename Key>
433 noexcept(std::is_nothrow_move_constructible_v<Key>
and
434 std::is_nothrow_default_constructible_v<Data>
and
435 std::is_nothrow_copy_assignable_v<Endpoint>)
449 noexcept(std::is_nothrow_move_constructible_v<Key>
and
450 std::is_nothrow_move_constructible_v<Data>)
487 template <
typename Key>
490 template <
typename Key>
495 template <
class Node>
498 template <
class Node>
501 return p->getMaxEndpoint();
504 namespace interval_tree_detail
516 template <
typename T,
bool = std::is_nothrow_copy_assignable_v<T>>
549 template <
typename T>
566 void give(
T &
max)
noexcept(std::is_nothrow_move_assignable_v<T>)
568 if (not
copy.has_value())
570 if constexpr (std::is_move_assignable_v<T>)
600 template <
template <
typename>
class NodeType,
603 requires StrictWeakOrder<Compare, T>
623 return static_cast<unsigned int>(
seed)
643 return step->left ?
LLINK(step->node) :
RLINK(step->node);
686 const T & high =
KEY(p).high;
692 Step *above = bottom;
693 const T *lmax =
nullptr;
694 const T *rmax =
nullptr;
698 const T *& side = above->
left ? rmax : lmax;
699 const T *
max = std::addressof(
KEY(q).high);
711 const T *
max = std::addressof(high);
716 if (
max != std::addressof(high))
728 for (
Step *s = bottom; s != whole; s = s->
up)
729 s->max.give(
MAX_EP(s->node));
732 Node *
l = Node::NullPtr;
733 Node *
r = Node::NullPtr;
734 for (
Step *s = bottom; s != above; s = s->
up)
754 if (
root == Node::NullPtr)
762 return Node::NullPtr;
771 if (
root == Node::NullPtr)
802 if (t1 == Node::NullPtr or t2 == Node::NullPtr)
806 for (
Step *s = up; s != whole; s = s->
up)
807 s->max.give(
MAX_EP(s->node));
808 for (
Step *s = spine; s !=
nullptr; s = s->
up)
809 s->max.give(
MAX_EP(s->node));
810 return t1 == Node::NullPtr ? t2 : t1;
817 const bool first =
PRIO(t1) <
PRIO(t2);
818 Node *top = first ? t1 : t2;
819 Node *other = first ? t2 : t1;
825 :
join(t1,
LLINK(t2), up, whole, &grown);
843 const T & high =
KEY(p).high;
855 const T *below =
nullptr;
856 for (
bool first =
true;
858 whole = whole->
up, first =
false)
862 if (t1 != Node::NullPtr)
863 below = std::addressof(
MAX_EP(t1));
864 if (t2 != Node::NullPtr
and
865 (below ==
nullptr or
less(*below,
MAX_EP(t2))))
866 below = std::addressof(
MAX_EP(t2));
869 const T *
max = std::addressof(
KEY(q).high);
879 Node *joined =
join(t1, t2, &self, whole,
nullptr);
888 if (
root == Node::NullPtr)
889 return Node::NullPtr;
904 Op & op,
const Compare &
cmp)
906 if (
root == Node::NullPtr)
931 if (
root == Node::NullPtr)
950 if (
root == Node::NullPtr)
986 noexcept(
noexcept(std::swap(
tree_root, tree.tree_root))
and
987 noexcept(std::swap(
cmp, tree.cmp))
and
989 noexcept(std::swap(
num_nodes, tree.num_nodes)))
992 std::swap(
cmp, tree.cmp);
1007 const Compare & _cmp = Compare())
1054 [[deprecated(
"it makes a Mersenne Twister in a tree that has none: "
1055 "use random_source(); it goes in 8.0.0")]]
1067 [[deprecated(
"the generator is no longer of GSL: use random_source(); it goes in 8.0.0")]]
1068 [[nodiscard]] gsl_rng * gsl_rng_object()
const {
return r.gsl(); }
1094 noexcept(std::is_nothrow_copy_constructible_v<Compare>
and
1098 return ret_val == Node::NullPtr ? nullptr : ret_val;
1118 assert(p != Node::NullPtr);
1120 p->getMaxEndpoint() =
KEY(p).high;
1138 assert(p != Node::NullPtr);
1140 p->getMaxEndpoint() =
KEY(p).high;
1164 if (ret_val == Node::NullPtr)
1180 while (x != Node::NullPtr)
1182 if (
KEY(x).overlaps(query,
cmp))
1277 template <
typename T,
class Compare = Aleph::less<T>>
1278 requires StrictWeakOrder<Compare, T>
1292 template <
typename T,
class Compare = Aleph::less<T>>
1327 template <
typename T,
class Compare = Aleph::less<T>>
1332 public GenericKeys<DynIntervalTree<T, Compare>, Interval<T>>,
1367 const Compare &
cmp = Compare())
1414 noexcept(
noexcept(std::declval<Tree &>().swap(std::declval<Tree &>())))
1430 noexcept(
noexcept(std::declval<Tree &>().swap(std::declval<Tree &>())))
1454 <<
"Invalid interval: low > high";
1455 std::unique_ptr<Node> p(
new Node(iv));
1457 if (result ==
nullptr)
1481 <<
"Invalid interval: low > high";
1488 ~Guard() {
delete p; }
1489 } guard{
new Node(std::move(iv))};
1492 if (result ==
nullptr)
1527 <<
"Invalid interval: low > high";
1531 ~Guard() {
delete p; }
1532 } guard{
new Node(iv)};
1586 noexcept(
noexcept(std::declval<const Tree &>().search(iv)))
1589 return p !=
nullptr ? &
KEY(p) :
nullptr;
1601 return p !=
nullptr ? &
KEY(p) :
nullptr;
1657 tree.
stab(p, std::forward<Op>(op));
1681 [[nodiscard]]
auto key_comp() const noexcept(
std::is_nothrow_copy_constructible_v<Compare>)
1712 template <
class Operation>
1718 return op(p->get_key());
1728 template <
class Operation>
1732 return traverse<Operation>(op);
1741 template <
class Operation>
1747 return op(p->get_key());
1757 template <
class Operation>
1761 return traverse<Operation>(op);
C++20 concepts hub: comparison, BST policy, and Aleph container concepts.
Container traversal and functional operation mixins.
Exception handling system with formatted messages for Aleph-w.
#define ah_domain_error()
Throws std::domain_error unconditionally.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
The random number generators of Aleph: the one that gives the numbers of the gsl_rng_mt19937 of GSL,...
SentinelCtor
Tag type for sentinel node construction.
DRY (Don't Repeat Yourself) utilities and macros.
#define Special_Ctors(Set_Type, Type)
Generates special constructors for containers.
Standard functor implementations and comparison objects.
WeightedDigraph::Node Node
Inorder iterator on the nodes of a binary tree.
Node * get_curr_ne() const noexcept
Return the current link guaranteeing no exception. Be careful.
void next()
Move the iterator one position forward.
Node * get_curr() const
Return the current node. Throw overflow_error if there is no current.
bool has_curr() const noexcept
Return true the iterator has current node.
void next_ne()
Move forward without checking the position; it may throw bad_alloc, as the constructor does.
void reset_first()
Reset the iterator to the first node inorder; it may throw bad_alloc, as the constructor does.
size_t get_pos() const
Return the current position of iterator. Only valid if has_curr() == true.
Inorder iterator yielding Interval<T> keys.
bool has_curr() const noexcept
Check if there is a current element.
void end() noexcept
Move to the position after the last element.
size_t get_pos() const
Return the 0-indexed current position.
void reset_first() noexcept(noexcept(it.reset_first()))
Reset to the first element in traversal order.
const Key & get_curr_ne() const noexcept
Return the current interval (no check).
void next_ne() noexcept(noexcept(it.next_ne()))
Advance to the next element (no check).
void next()
Advance to the next element.
Iterator() noexcept=default
Default constructor.
const Key & get_curr() const
Return the current interval.
High-level interval tree with automatic memory management.
Key & insert(const T &lo, const T &hi)
Insert an interval given endpoints (unique).
DynList< Key > find_all_overlaps(const Key &query) const
Find all overlapping intervals.
const Key * search(const Key &iv) const noexcept(noexcept(std::declval< const Tree & >().search(iv)))
Search for an exact interval.
DynIntervalTree(const unsigned long seed, const Compare &cmp=Compare())
Construct with explicit seed for the internal RNG.
DynList< Key > find_stab(const T &p) const
Find all intervals containing point p.
DynList< Key > find_all_overlaps(const T &lo, const T &hi) const
Overload of find_all_overlaps() using endpoints.
bool is_empty() const noexcept
Return true if the tree contains no intervals.
Key & insert_dup(const Key &iv)
Insert interval, allowing duplicates.
void copy_from(const DynIntervalTree &src)
auto key_comp() const noexcept(std::is_nothrow_copy_constructible_v< Compare >)
Return the comparator that orders the intervals: by low endpoint, then by high endpoint.
Key & insert(const Key &iv)
Insert an interval (unique).
const Key * overlap_search(const T &lo, const T &hi) const
Overload of overlap_search() using endpoints.
const Key * overlap_search(const Key &query) const
Find any interval overlapping query.
void all_overlaps(const Key &query, Op &&op) const
Apply op to every overlapping interval.
void swap(DynIntervalTree &other) noexcept(noexcept(std::declval< Tree & >().swap(std::declval< Tree & >())))
Swap state with another tree in O(1).
DynIntervalTree & operator=(const DynIntervalTree &src)
Copy assignment.
bool verify() const
Verify all tree invariants (BST, Treap, MaxEndpoint).
Key & append(const Key &iv)
Append an interval (alias for insert_dup).
DynIntervalTree(DynIntervalTree &&src)
Move constructor.
bool empty() const noexcept
Return true if the tree contains no intervals (STL compatible).
bool traverse(Operation &op)
Traverse all intervals in inorder (sorted by low endpoint).
void stab(const T &p, Op &&op) const
Apply op to every interval containing point p.
size_t size() const noexcept
Return the number of intervals in the tree.
bool remove(const T &lo, const T &hi)
Remove an interval given endpoints.
Key & insert(Key &&iv)
Insert an interval (move version, unique).
bool remove(const Key &iv)
Remove an interval from the tree.
bool traverse(Operation &op) const
Const overload of traverse().
bool traverse(Operation &&op=Operation()) const
Const rvalue overload of traverse().
bool traverse(Operation &&op=Operation())
Overload of traverse() for rvalue callbacks.
~DynIntervalTree()
Destructor.
typename Interval_Tree< T, Compare >::Node Node
DynIntervalTree(const Compare &cmp=Compare())
Default constructor.
DynIntervalTree(const DynIntervalTree &src)
Copy constructor.
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
Augmented treap storing intervals with overlap/stabbing queries.
Node * insert_dup(Node *p)
Insert a node (duplicates allowed).
DynList< Key > find_all_overlaps(const Key &query) const
Find all intervals overlapping query.
size_t size() const noexcept
Return the number of nodes.
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,...
bool verify() const
Verify BST, heap, and max_endpoint invariants.
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.
void unlink(Node *p, Step *up)
Take a node out of the tree: its two subtrees, joined, take its place.
Interval_Less< T, Compare > IntervalCmp
const Compare & endpoint_comp() const noexcept
Return the endpoint comparison functor (const)
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.
const Compare & get_compare() const noexcept
Backwards-compatible accessor for the endpoint comparator.
interval_tree_detail::Pending_Max< T > Pending
Node * remove(const Key &key)
Remove an interval from the tree.
IntervalCmp key_comp() const noexcept(std::is_nothrow_copy_constructible_v< Compare >)
Return the interval comparison functor (over Interval<T> keys).
void stab(const T &p, Op &&op) const
Apply op to every interval containing point p.
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...
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 f...
Node *& getRoot() noexcept
Return the tree's root.
static void all_overlaps(Node *root, const Key &query, Op &op, const Compare &cmp)
Recursive: find all intervals overlapping query.
Node * insert(Node *p)
Insert a node (no duplicates).
static unsigned long generator_seed(const unsigned long seed) noexcept
Gen_Interval_Tree(const Compare &_cmp=Compare())
Construct without a seed: the priorities are drawn from a SplitMix64 with a seed of its own,...
Gen_Interval_Tree & operator=(const Gen_Interval_Tree &)=delete
Deleted copy assignment.
Node *& link_from(Step *step) noexcept
The link that hangs from a step: that of the root if there is none.
Gen_Interval_Tree(const Gen_Interval_Tree &)=delete
Deleted copy constructor.
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 * overlap_search(const Key &query) const
Find any interval that overlaps with query (CLRS algorithm).
static bool check_max(Node *root, const Compare &cmp)
Verify max_endpoint invariant.
Random_Source & random_source() noexcept
The source of random numbers, which gives the priorities.
void place(Node *p, Step *bottom)
Put a node in its place, at the end of the way down.
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 o...
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 all_overlaps(const Key &query, Op &&op) const
Apply op to every interval overlapping query.
static size_t count_nodes(Node *root) noexcept
DynList< Key > find_stab(const T &p) const
Find all intervals containing point p.
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.
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.
Gen_Interval_Tree(Gen_Interval_Tree &&)=delete
Deleted move constructor.
const Node * getRoot() const
Return the tree's root (const)
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.
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)
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.
A random number generator with the sequences of GSL's gsl_rng_mt19937.
static constexpr result_type max() noexcept
The greatest number of operator()(): 2^32 - 1.
Interval tree node with virtual destructor.
void reset() noexcept(std::is_nothrow_copy_assignable_v< Endpoint >)
Leave the node as one that is in no tree: without links, and with the high endpoint of its interval a...
virtual ~Interval_Tree_NodeVtl()=default
Virtual destructor.
const Interval_Tree_NodeVtl * getL() const noexcept
interval_endpoint_t< Key > Endpoint
static Interval_Tree_NodeVtl *const NullPtr
const Key & get_key() const noexcept
Interval_Tree_NodeVtl *& getL() noexcept
Interval_Tree_NodeVtl * rLink
Interval_Tree_NodeVtl(const Interval_Tree_NodeVtl &node)
Interval_Tree_NodeVtl * lLink
Interval_Tree_NodeVtl *& getR() noexcept
static Interval_Tree_NodeVtl sentinel_node
The sentinel node instance (virtual version).
Interval_Tree_NodeVtl(const Key &k)
Interval_Tree_NodeVtl(Interval_Tree_NodeVtl &&node) noexcept(std::is_nothrow_move_constructible_v< Key > and std::is_nothrow_move_constructible_v< Data >)
Interval_Tree_NodeVtl(Key &&k) noexcept(std::is_nothrow_move_constructible_v< Key > and std::is_nothrow_default_constructible_v< Data > and std::is_nothrow_copy_assignable_v< Endpoint >)
const Interval_Tree_NodeVtl * getR() const noexcept
Interval_Tree_NodeVtl(SentinelCtor)
static constexpr size_t MaxHeight
Data portion of an interval tree node.
Interval_Tree_Node_Data() noexcept(std::is_nothrow_default_constructible_v< T >)
T & getMaxEndpoint() noexcept
const T & getMaxEndpoint() const noexcept
unsigned long & getPriority() noexcept
Interval_Tree_Node_Data(SentinelCtor) noexcept(std::is_nothrow_default_constructible_v< T >)
static void reset() noexcept
Interval tree node with sentinel support.
Interval_Tree_Node *& getR() noexcept
Interval_Tree_Node(const Key &k)
const Interval_Tree_Node * getR() const noexcept
void reset() noexcept(std::is_nothrow_copy_assignable_v< Endpoint >)
Leave the node as one that is in no tree: without links, and with the high endpoint of its interval a...
const Key & get_key() const noexcept
Interval_Tree_Node(SentinelCtor)
static constexpr size_t MaxHeight
static Interval_Tree_Node *const NullPtr
interval_endpoint_t< Key > Endpoint
static Interval_Tree_Node sentinel_node
The sentinel node instance.
Interval_Tree_Node(Key &&k) noexcept(std::is_nothrow_move_constructible_v< Key > and std::is_nothrow_default_constructible_v< Data > and std::is_nothrow_copy_assignable_v< Endpoint >)
Interval_Tree_Node(Interval_Tree_Node &&node) noexcept(std::is_nothrow_move_constructible_v< Key > and std::is_nothrow_move_constructible_v< Data >)
Interval_Tree_Node * lLink
Interval_Tree_Node *& getL() noexcept
const Interval_Tree_Node * getL() const noexcept
Interval_Tree_Node(const Interval_Tree_Node &node)
Interval_Tree_Node * rLink
The source of random numbers of a randomized structure, which draws from one of two generators.
@ Mersenne_Twister
A Gsl_Compatible_Rng, in dynamic memory.
unsigned long get() noexcept
The next number, as operator()().
Gsl_Compatible_Rng & mersenne_twister()
The Mersenne Twister of the source, which is its engine from now on.
void seed(const std::uint64_t s) noexcept
Draws from now on from the SplitMix64 of a seed.
void swap(Random_Source &o) noexcept
Swaps the generators, with their states.
Minimal std::expected-style result type for C++20.
void set(const T &max)
Take note of the new maximum.
void give(T &max) noexcept(std::is_nothrow_move_assignable_v< T >)
Give the node its new maximum, if it has one.
std::optional< T > copy
The new maximum, if there is one.
What the maximum endpoint of a node is to become.
void set(const T &max) noexcept
Take note of the new maximum.
void give(T &max) const noexcept
Give the node its new maximum, if it has one.
const T * from
Where the new maximum is, if there is one.
Equality test for containers sorted by a comparator.
Common methods to the Aleph-w ( ) containers.
void for_each(Operation &operation) const
Traverse all the container and performs an operation on each element.
Mixin that adds STL begin()/end() and cbegin()/cend() to Aleph containers.
PredicateWith<F, Args...>, and neither the call nor the conversion of its result to bool can throw.
f(args...) is a valid call whose result is usable as a condition.
Strict weak ordering constraint for BST comparators.
__gmp_expr< typename __gmp_resolve_expr< T, V >::value_type, __gmp_binary_expr< __gmp_expr< T, U >, __gmp_expr< V, W >, __gmp_max_function > > max(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
__gmp_expr< T, __gmp_binary_expr< __gmp_expr< T, U >, unsigned long int, __gmp_root_function > > root(const __gmp_expr< T, U > &expr, unsigned long int l)
int cmp(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
bool traverse(Node *root, Op op)
See infix_traverse().
bool check_bst(Node *p, const Compare &cmp=Compare())
Return true if p is a binary search tree.
void destroyRec(Node *&root) noexcept
Free all the memory occupied by the tree root
unsigned long & PRIO(Node *p) noexcept
Access the priority of a treap node.
Node * searchInBinTree(Node *root, const typename Node::key_type &key, const Compare &cmp=Compare()) noexcept(nothrow_compare_v< Compare, typename Node::key_type >)
Search a key in a binary search tree using optimistic search.
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
typename interval_endpoint< Key >::type interval_endpoint_t
auto & MAX_EP(Node *p) noexcept
Access max_endpoint of an interval tree node.
bool is_treap(Node *root) noexcept
Validate that a tree satisfies treap (heap) property.
static long & low(typename GT::Node *p)
Internal helper: low-link value stored directly in NODE_COOKIE(p).
Itor2 copy(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg)
Copy elements from one range to another.
std::decay_t< typename HeadC::Item_Type > T
and
Check uniqueness with explicit hash + equality functors.
const long Max_Priority
Maximum priority value (used for sentinel/leaves)
const long Min_Priority
Minimum priority value.
Inorder iterator over nodes.
Iterator() noexcept=default
A step of the way down from the root: a node, and the side taken there.
Pending max
The new maximum of the node, if it changes.
bool left
True if the way goes on through the left link.
Step * up
The step above; nullptr at the root.
BST comparator for intervals: order by (low, then high).
bool operator()(const Interval< T > &a, const Interval< T > &b) const noexcept(NothrowPredicateWith< const Compare &, const T &, const T & >)
Comparison operator.
Interval_Less(const Compare &c=Compare()) noexcept(std::is_nothrow_copy_constructible_v< Compare >)
Constructor.
Interval tree using nodes with virtual destructor.
Interval tree using nodes without virtual destructor.
Closed interval [low, high].
bool contains(const T &p, const Compare &cmp=Compare()) const noexcept(NothrowPredicateWith< const Compare &, const T &, const T & >)
Return true if this interval contains the point p.
static Interval point(const T &p) noexcept(std::is_nothrow_copy_constructible_v< T >)
Construct a point interval [p, p].
bool operator==(const Interval &other) const noexcept(noexcept(static_cast< bool >(std::declval< const T & >()==std::declval< const T & >())))
Equality operator.
Interval() noexcept(std::is_nothrow_default_constructible_v< T >)
Initializes the interval as [T{}, T{}].
bool is_valid(const Compare &cmp=Compare()) const noexcept(NothrowPredicateWith< const Compare &, const T &, const T & >)
Return true if low <= high.
bool overlaps(const Interval &other, const Compare &cmp=Compare()) const noexcept(NothrowPredicateWith< const Compare &, const T &, const T & >)
Return true if this interval overlaps with other.
Interval(T &&lo, T &&hi) noexcept(std::is_nothrow_move_constructible_v< T >)
Construct interval [lo, hi] (move version).
bool operator!=(const Interval &other) const noexcept(noexcept(*this==other))
Inequality operator.
Interval(const T &lo, const T &hi) noexcept(std::is_nothrow_copy_constructible_v< T >)
Construct interval [lo, hi].
Trait to extract endpoint type from Interval<T>.
Generic list of items stored in a container.
Utility functions for binary tree operations.
Binary tree operations (split, join, rotate).
Treap node definition with BST key and heap priority.