Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::DynIntervalTree< T, Compare > Class Template Reference

High-level interval tree with automatic memory management. More...

#include <tpl_interval_tree.H>

Inheritance diagram for Aleph::DynIntervalTree< T, Compare >:
[legend]
Collaboration diagram for Aleph::DynIntervalTree< T, Compare >:
[legend]

Classes

class  Iterator
 Inorder iterator yielding Interval<T> keys. More...
 

Public Types

using Key = Interval< T >
 
using Item_Type = Key
 
using Key_Type = Key
 
using Node = typename Interval_Tree< T, Compare >::Node
 
using Tree = Interval_Tree< T, Compare >
 
- Public Types inherited from StlAlephIterator< SetName >
using iterator = StlIterator< SetName >
 
using const_iterator = StlConstIterator< SetName >
 

Public Member Functions

 DynIntervalTree (const Compare &cmp=Compare())
 Default constructor.
 
 DynIntervalTree (const unsigned long seed, const Compare &cmp=Compare())
 Construct with explicit seed for the internal RNG.
 
 DynIntervalTree (const DynIntervalTree &src)
 Copy constructor.
 
 DynIntervalTree (DynIntervalTree &&src)
 Move constructor.
 
DynIntervalTree & operator= (const DynIntervalTree &src)
 Copy assignment.
 
DynIntervalTree & operator= (DynIntervalTree &&src) noexcept(noexcept(std::declval< Tree & >().swap(std::declval< Tree & >())))
 Move assignment.
 
 ~DynIntervalTree ()
 Destructor.
 
void swap (DynIntervalTree &other) noexcept(noexcept(std::declval< Tree & >().swap(std::declval< Tree & >())))
 Swap state with another tree in O(1).
 
template<template< typename > class List>
 DynIntervalTree (const List< Key > &l)
 
template<class It >
requires (not std::is_arithmetic_v<It> and requires (It it) { *it; ++it; it != it; })
 DynIntervalTree (It b, It e)
 
 DynIntervalTree (std::initializer_list< Key > l)
 
Key & insert (const Key &iv)
 Insert an interval (unique).
 
Key & insert (Key &&iv)
 Insert an interval (move version, unique).
 
Key & insert (const T &lo, const T &hi)
 Insert an interval given endpoints (unique).
 
Key & insert_dup (const Key &iv)
 Insert interval, allowing duplicates.
 
Key & append (const Key &iv)
 Append an interval (alias for insert_dup).
 
bool remove (const Key &iv)
 Remove an interval from the tree.
 
bool remove (const T &lo, const T &hi)
 Remove an interval given endpoints.
 
const Key * search (const Key &iv) const noexcept(noexcept(std::declval< const Tree & >().search(iv)))
 Search for an exact interval.
 
const Key * overlap_search (const Key &query) const
 Find any interval overlapping query.
 
const Key * overlap_search (const T &lo, const T &hi) const
 Overload of overlap_search() using endpoints.
 
template<class Op >
void all_overlaps (const Key &query, Op &&op) const
 Apply op to every overlapping interval.
 
DynList< Key > find_all_overlaps (const Key &query) const
 Find all overlapping intervals.
 
DynList< Key > find_all_overlaps (const T &lo, const T &hi) const
 Overload of find_all_overlaps() using endpoints.
 
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.
 
size_t size () const noexcept
 Return the number of intervals in the tree.
 
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.
 
bool is_empty () const noexcept
 Return true if the tree contains no intervals.
 
bool empty () const noexcept
 Return true if the tree contains no intervals (STL compatible).
 
bool verify () const
 Verify all tree invariants (BST, Treap, MaxEndpoint).
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const Key &>
bool traverse (Operation &op)
 Traverse all intervals in inorder (sorted by low endpoint).
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const Key &>
bool traverse (Operation &&op=Operation())
 Overload of traverse() for rvalue callbacks.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const Key &>
bool traverse (Operation &op) const
 Const overload of traverse().
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const Key &>
bool traverse (Operation &&op=Operation()) const
 Const rvalue overload of traverse().
 
- Public Member Functions inherited from EqualSortedMethod< Container >
bool equal_to (const Container &r) const
 Equality test between this and r.
 
- Public Member Functions inherited from FunctionalMethods< Container, T >
void emplace (Args &&... args)
 Appends a new element into the container by constructing it from the given args.
 
void emplace_end (Args &&... args)
 See emplace(Args && ... args).
 
void emplace_ins (Args &&... args)
 
template<typename... Args>
requires ((std::convertible_to<Args &&, T> and ...) and (Aleph::InsertableWith<typename Aleph::concepts_detail::defer<Container, std::tuple<Args...>>::type, Item_Arg<Args>> and ...))
size_t ninsert (Args &&... args)
 Insert n variadic items.
 
template<typename... Args>
requires ((std::convertible_to<Args &&, T> and ...) and (Aleph::AppendableWith<typename Aleph::concepts_detail::defer<Container, std::tuple<Args...>>::type, Item_Arg<Args>> and ...))
size_t nappend (Args &&... args)
 Append n variadic items.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void for_each (Operation &operation) const
 Traverse all the container and performs an operation on each element.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void for_each (Operation &&operation) const
 Overload of for_each() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void each (Operation &operation) const
 Alias of for_each().
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void each (Operation &&operation) const
 Alias of for_each() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void each (const size_t pos, const size_t slice, Operation &operation) const
 Traverse the container starting at pos taking one item every slice, performing an operation on each visited element.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void each (const size_t pos, const size_t slice, Operation &&operation) const
 See each(size_t pos, size_t slice, Operation & operation) const.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, T &>
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void each (const size_t pos, const size_t slice, Operation &operation)
 Traverse the container starting at pos taking one item every slice, performing an operation that may modify each visited item.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, T &>
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void each (const size_t pos, const size_t slice, Operation &&operation)
 See each(size_t pos, size_t slice, Operation & operation).
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, T &>
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void mutable_for_each (Operation &operation)
 Apply a mutable operation to each element of the container.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, T &>
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void mutable_for_each (Operation &&operation)
 See mutable_for_each(Operation & operation).
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
bool all (Operation &operation) const
 Check if all the elements of the container satisfy a condition.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
bool all (Operation &&operation) const
 Overload of all() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
bool exists (Operation &op) const
 Test for existence in the container of an element satisfying a criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
bool exists (Operation &&op) const
 Overload of exists() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
bool none (Operation &op) const
 Test that no element satisfies a criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
bool none (Operation &&op) const
 Overload of none() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
size_t count_if (Operation &op) const
 Count the elements that satisfy a criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
size_t count_if (Operation &&op) const
 Overload of count_if() that accepts rvalues.
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps (Operation &op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps (Operation &&op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps_if (Prop prop, Operation &op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps_if (Prop prop, Operation &&op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > map (Operation &op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > map (Operation &&op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > map_if (Prop prop, Operation &op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > map_if (Prop prop, Operation &&op) const
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
auto flat_map (Operation &op) const
 Map each element to a container and concatenate the results.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
auto flat_map (Operation &&op) const
 Overload of flat_map() that accepts rvalues.
 
Aleph::DynList< T > to_dynlist () const
 Convert container to DynList.
 
std::vector< T > to_vector () const
 Convert container to std::vector.
 
template<typename Acc = T, class Op >
requires Aleph::dry_detail::FoldOperation<Op, Acc, T>
Acc foldl (const Acc &init, Op &op) const
 Fold the elements of the container to a specific result.
 
template<typename Acc = T, class Op >
requires Aleph::dry_detail::FoldOperation<Op, Acc, T>
Acc foldl (const Acc &init, Op &&op) const
 Overload of foldl() that accepts rvalues.
 
template<typename Acc = T, class Op >
requires Aleph::dry_detail::FoldOperation<Op, Acc, T>
Acc fold_left (const Acc &init, Op &op) const
 Alias for foldl().
 
template<typename Acc = T, class Op >
requires Aleph::dry_detail::FoldOperation<Op, Acc, T>
Acc fold_left (const Acc &init, Op &&op) const
 Overload of fold_left() that accepts rvalues.
 
template<class Operation >
requires Aleph::dry_detail::FoldOperation<Operation, T, T>
T fold (const T &init, Operation &operation) const
 Simplified version of foldl() where the folded type is the same type of elements stored in the container.
 
template<class Operation >
requires Aleph::dry_detail::FoldOperation<Operation, T, T>
T fold (const T &init, Operation &&operation) const
 Overload of fold() that accepts rvalues.
 
template<typename Acc = T, class Op >
requires Aleph::dry_detail::FoldRightOperation<Op, Acc, T>
Acc foldr (const Acc &init, Op &op) const
 Fold the elements from the last to the first.
 
template<typename Acc = T, class Op >
requires Aleph::dry_detail::FoldRightOperation<Op, Acc, T>
Acc foldr (const Acc &init, Op &&op) const
 Overload of foldr() that accepts rvalues.
 
template<class Op , class U = T>
requires Aleph::dry_detail::FoldOperation<Op, T, T>
and std::copy_constructible< U > std::optional< T > reduce (Op &op) const
 Fold the elements with no initial value.
 
template<class Op , class U = T>
requires Aleph::dry_detail::FoldOperation<Op, T, T>
and std::copy_constructible< U > std::optional< T > reduce (Op &&op) const
 Overload of reduce() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< T > filter (Operation &operation) const
 Filter the elements of a container according to a matching criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< T > filter (Operation &&operation) const
 Overload of filter() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< const T * > ptr_filter (Operation &operation) const
 Filter the elements of a container according to a matching criterion and return a pointer to the matched items in the container.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< const T * > ptr_filter (Operation &&operation) const
 Overload of ptr_filter() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< std::tuple< T, size_t > > pfilter (Operation &operation) const
 Filter the elements of a container according to a matching criterion and determine its positions respect to the traversal of container.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< std::tuple< T, size_t > > pfilter (Operation &&operation) const
 Overload of pfilter() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition (Operation &op) const
 Exclusive partition of container according to a filter criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition (Operation &&op) const
 Overload of partition() that accepts rvalues.
 
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition (size_t n) const
 Exclusive partition of container in the nth item.
 
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > split_half () const
 Split the container into two halves by alternating elements.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > tpartition (Operation &op) const
 Exclusive partition of container according to a filter criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > tpartition (Operation &&op) const
 Overload of tpartition() that accepts rvalues.
 
size_t length () const noexcept(Aleph::dry_detail::const_traversal_is_noexcept< Container, T >)
 Count the number of elements of a container.
 
Aleph::DynList< T > rev () const
 Return a list with the elements of container in reverse order respect to its traversal order.
 
Aleph::DynList< T > take (const size_t n) const
 Return a list with the first n elements seen in the container during its traversal.
 
Aleph::DynList< T > take (size_t i, const size_t j, const size_t step=1) const
 Return a list with the elements at positions i, i + step, i + 2 step, ... that are not greater than j, respect to the traversal order.
 
Aleph::DynList< T > drop (const size_t n) const
 Drop the first n elements seen in the container during its traversal.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< T > take_while (Operation &op) const
 The longest prefix of elements that satisfy a criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< T > take_while (Operation &&op) const
 Overload of take_while() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< T > drop_while (Operation &op) const
 The elements after the longest prefix that satisfies a criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< T > drop_while (Operation &&op) const
 Overload of drop_while() that accepts rvalues.
 
template<class C = Container>
requires requires (C & c) { c.remove(); }
void mutable_drop (const size_t n)
 Drop the first n elements seen from container.
 
- Public Member Functions inherited from GenericItems< Container, T >
Aleph::DynList< T > items () const
 Return a list of all the elements of a container sorted by traversal order.
 
Aleph::DynList< T > keys () const
 See items().
 
- Public Member Functions inherited from StlAlephIterator< SetName >
iterator begin () noexcept
 Return an STL-compatible iterator to the first element.
 
iterator end () noexcept
 Return an STL-compatible end iterator.
 
const_iterator begin () const noexcept
 Return a const iterator to the first element.
 
const_iterator end () const noexcept
 Return a const end iterator.
 
const_iterator cbegin () const noexcept
 Return a const iterator to the first element.
 
const_iterator cend () const noexcept
 Return a const end iterator.
 

Private Member Functions

void copy_from (const DynIntervalTree &src)
 
void destroy_tree ()
 

Private Attributes

Tree tree
 

Additional Inherited Members

- Static Public Member Functions inherited from FunctionalMethods< Container, T >
template<typename... Items>
requires ((std::convertible_to<Items &&, T> and ...) and (Aleph::AppendableWith<typename Aleph::concepts_detail::defer<Container, std::tuple<Items...>>::type, Item_Arg<Items>> and ...))
static Container build (Items &&... items)
 Build a container that holds the given items.
 
template<class D , typename... Items>
requires (std::derived_from<D, typename Aleph::concepts_detail::defer<Container, D>::type> and std::default_initializable<D> and (std::convertible_to<Items &&, T> and ...) and (Aleph::AppendableWith<typename Aleph::concepts_detail::defer<Container, std::tuple<D, Items...>>::type, Item_Arg<Items>> and ...))
static D build_as (Items &&... items)
 Build a D, a class derived from the container, holding the given items.
 
- Public Attributes inherited from FunctionalMethods< Container, T >
template<typename... Args>
requires (typename Aleph::concepts_detail::defer<Container, std::tuple<Args...>>::type & c, T && x)
 and { c.append(std::move(x))
 Insert a new element into the container by constructing it from the given args.
 
template<typename R = void, class Prop , class Operation >
requires (Aleph::DynList<Aleph::dry_detail::map_result_t<R, Operation &, T>> & l, Operation & op, const T & item)
and Aleph::InvocableWith< Operation &, const T & > and { l.append(std::invoke(op, item))
 Conditional mapping of the elements of the container.
 

Detailed Description

template<typename T, class Compare = Aleph::less<T>>
requires StrictWeakOrder<Compare, T>
class Aleph::DynIntervalTree< T, Compare >

High-level interval tree with automatic memory management.

DynIntervalTree<T> wraps Interval_Tree<T> and provides:

  • Automatic new/delete for nodes
  • CRTP mixins for functional methods
  • Validation on insert (low <= high)
  • Copy/move semantics
Template Parameters
TEndpoint type.
CompareComparison functor for endpoints.
Example:
tree.insert(3, 10);
// Find any overlap with [4, 7]
auto result = tree.overlap_search({4, 7});
// Find all intervals containing point 6
auto hits = tree.find_stab(6);
High-level interval tree with automatic memory management.
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...
const Node * overlap_search(const Key &query) const
Find any interval that overlaps with query (CLRS algorithm).
DynList< Key > find_stab(const T &p) const
Find all intervals containing point p.
Closed interval [low, high].

Definition at line 1329 of file tpl_interval_tree.H.

Member Typedef Documentation

◆ Item_Type

template<typename T , class Compare = Aleph::less<T>>
using Aleph::DynIntervalTree< T, Compare >::Item_Type = Key

Definition at line 1337 of file tpl_interval_tree.H.

◆ Key

template<typename T , class Compare = Aleph::less<T>>
using Aleph::DynIntervalTree< T, Compare >::Key = Interval<T>

Definition at line 1336 of file tpl_interval_tree.H.

◆ Key_Type

template<typename T , class Compare = Aleph::less<T>>
using Aleph::DynIntervalTree< T, Compare >::Key_Type = Key

Definition at line 1338 of file tpl_interval_tree.H.

◆ Node

template<typename T , class Compare = Aleph::less<T>>
using Aleph::DynIntervalTree< T, Compare >::Node = typename Interval_Tree<T, Compare>::Node

Definition at line 1339 of file tpl_interval_tree.H.

◆ Tree

template<typename T , class Compare = Aleph::less<T>>
using Aleph::DynIntervalTree< T, Compare >::Tree = Interval_Tree<T, Compare>

Definition at line 1340 of file tpl_interval_tree.H.

Constructor & Destructor Documentation

◆ DynIntervalTree() [1/7]

template<typename T , class Compare = Aleph::less<T>>
Aleph::DynIntervalTree< T, Compare >::DynIntervalTree ( const Compare &  cmp = Compare())
inline

Default constructor.

Parameters
[in]cmpComparison functor for endpoints.

Definition at line 1360 of file tpl_interval_tree.H.

◆ DynIntervalTree() [2/7]

template<typename T , class Compare = Aleph::less<T>>
Aleph::DynIntervalTree< T, Compare >::DynIntervalTree ( const unsigned long  seed,
const Compare &  cmp = Compare() 
)
inline

Construct with explicit seed for the internal RNG.

Parameters
[in]seedRandom seed.
[in]cmpComparison functor for endpoints.

Definition at line 1366 of file tpl_interval_tree.H.

◆ DynIntervalTree() [3/7]

template<typename T , class Compare = Aleph::less<T>>
Aleph::DynIntervalTree< T, Compare >::DynIntervalTree ( const DynIntervalTree< T, Compare > &  src)
inline

◆ DynIntervalTree() [4/7]

template<typename T , class Compare = Aleph::less<T>>
Aleph::DynIntervalTree< T, Compare >::DynIntervalTree ( DynIntervalTree< T, Compare > &&  src)
inline

Move constructor.

Not declared noexcept because the initializer tree(src.tree.endpoint_comp()) constructs a new Tree, which builds the key of its header node and copies the comparator — both can throw.

Parameters
[in,out]srcSource tree to move from.

Definition at line 1390 of file tpl_interval_tree.H.

References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::swap(), and Aleph::DynIntervalTree< T, Compare >::tree.

◆ ~DynIntervalTree()

template<typename T , class Compare = Aleph::less<T>>
Aleph::DynIntervalTree< T, Compare >::~DynIntervalTree ( )
inline

Destructor.

Definition at line 1424 of file tpl_interval_tree.H.

References Aleph::DynIntervalTree< T, Compare >::destroy_tree().

◆ DynIntervalTree() [5/7]

template<typename T , class Compare = Aleph::less<T>>
template<template< typename > class List>
Aleph::DynIntervalTree< T, Compare >::DynIntervalTree ( const List< Key > &  l)
inline

Definition at line 1435 of file tpl_interval_tree.H.

◆ DynIntervalTree() [6/7]

template<typename T , class Compare = Aleph::less<T>>
template<class It >
requires (not std::is_arithmetic_v<It> and requires (It it) { *it; ++it; it != it; })
Aleph::DynIntervalTree< T, Compare >::DynIntervalTree ( It  b,
It  e 
)
inline

Definition at line 1435 of file tpl_interval_tree.H.

◆ DynIntervalTree() [7/7]

template<typename T , class Compare = Aleph::less<T>>
Aleph::DynIntervalTree< T, Compare >::DynIntervalTree ( std::initializer_list< Key >  l)
inline

Definition at line 1435 of file tpl_interval_tree.H.

Member Function Documentation

◆ all_overlaps()

template<typename T , class Compare = Aleph::less<T>>
template<class Op >
void Aleph::DynIntervalTree< T, Compare >::all_overlaps ( const Key &  query,
Op &&  op 
) const
inline

Apply op to every overlapping interval.

Template Parameters
OpCallable with signature void(const Key&).
Parameters
[in]querythe query interval.
[in]opcallable to invoke for each overlap.
Exceptions
Anyexception thrown by op.

Definition at line 1622 of file tpl_interval_tree.H.

References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::all_overlaps(), and Aleph::DynIntervalTree< T, Compare >::tree.

◆ append()

template<typename T , class Compare = Aleph::less<T>>
Key & Aleph::DynIntervalTree< T, Compare >::append ( const Key &  iv)
inline

Append an interval (alias for insert_dup).

Parameters
[in]ivthe interval to append.
Returns
reference to the stored key.
Exceptions
std::domain_errorif iv.low > iv.high.

Definition at line 1544 of file tpl_interval_tree.H.

References Aleph::DynIntervalTree< T, Compare >::insert_dup().

Referenced by Aleph::DynIntervalTree< T, Compare >::copy_from(), and TEST().

◆ copy_from()

template<typename T , class Compare = Aleph::less<T>>
void Aleph::DynIntervalTree< T, Compare >::copy_from ( const DynIntervalTree< T, Compare > &  src)
inlineprivate

◆ destroy_tree()

◆ empty()

template<typename T , class Compare = Aleph::less<T>>
bool Aleph::DynIntervalTree< T, Compare >::empty ( ) const
inlinenoexcept

Return true if the tree contains no intervals (STL compatible).

Returns
true if empty.
Exceptions
none

Definition at line 1696 of file tpl_interval_tree.H.

References Aleph::DynIntervalTree< T, Compare >::is_empty().

◆ find_all_overlaps() [1/2]

template<typename T , class Compare = Aleph::less<T>>
DynList< Key > Aleph::DynIntervalTree< T, Compare >::find_all_overlaps ( const Key &  query) const
inline

Find all overlapping intervals.

Parameters
[in]querythe query interval.
Returns
DynList containing all overlapping intervals.

Definition at line 1632 of file tpl_interval_tree.H.

References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::find_all_overlaps(), and Aleph::DynIntervalTree< T, Compare >::tree.

Referenced by Aleph::DynIntervalTree< T, Compare >::find_all_overlaps(), meeting_scheduler(), segment_intersection(), and TEST().

◆ find_all_overlaps() [2/2]

template<typename T , class Compare = Aleph::less<T>>
DynList< Key > Aleph::DynIntervalTree< T, Compare >::find_all_overlaps ( const T &  lo,
const T &  hi 
) const
inline

Overload of find_all_overlaps() using endpoints.

Parameters
[in]lolower endpoint.
[in]hiupper endpoint.
Returns
DynList of overlapping intervals.

Definition at line 1642 of file tpl_interval_tree.H.

References Aleph::DynIntervalTree< T, Compare >::find_all_overlaps().

◆ find_stab()

template<typename T , class Compare = Aleph::less<T>>
DynList< Key > Aleph::DynIntervalTree< T, Compare >::find_stab ( const T &  p) const
inline

Find all intervals containing point p.

Parameters
[in]pquery point.
Returns
DynList of intervals containing p.

Definition at line 1664 of file tpl_interval_tree.H.

References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::find_stab(), and Aleph::DynIntervalTree< T, Compare >::tree.

Referenced by meeting_scheduler().

◆ insert() [1/3]

template<typename T , class Compare = Aleph::less<T>>
Key & Aleph::DynIntervalTree< T, Compare >::insert ( const Key &  iv)
inline

Insert an interval (unique).

Parameters
[in]ivthe interval to insert.
Returns
reference to the key stored in the tree.
Exceptions
std::domain_errorif iv.low > iv.high (invalid interval) or if the interval already exists in the tree.
whatthe comparison or the copy of an endpoint throw, and std::bad_alloc, with the tree as it was.
Note
If an assignment of an endpoint throws when the maxima are given, which only an endpoint whose copy assignment and whose move assignment may throw allows, the maxima of some nodes may be left changed: see Gen_Interval_Tree::insert(). The tree must then be destroyed, or built again from its intervals.

Definition at line 1451 of file tpl_interval_tree.H.

References ah_domain_error, ah_domain_error_if, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::endpoint_comp(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert(), Aleph::Interval< T >::is_valid(), KEY, and Aleph::DynIntervalTree< T, Compare >::tree.

Referenced by Aleph::DynIntervalTree< T, Compare >::insert(), meeting_scheduler(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST_F().

◆ insert() [2/3]

template<typename T , class Compare = Aleph::less<T>>
Key & Aleph::DynIntervalTree< T, Compare >::insert ( const T &  lo,
const T &  hi 
)
inline

Insert an interval given endpoints (unique).

Parameters
[in]lolower endpoint.
[in]hiupper endpoint.
Returns
reference to the key stored in the tree.
Exceptions
std::domain_errorif lo > hi or if the interval already exists.

Definition at line 1506 of file tpl_interval_tree.H.

References Aleph::DynIntervalTree< T, Compare >::insert().

◆ insert() [3/3]

template<typename T , class Compare = Aleph::less<T>>
Key & Aleph::DynIntervalTree< T, Compare >::insert ( Key &&  iv)
inline

Insert an interval (move version, unique).

Parameters
[in,out]ivthe interval to insert.
Returns
reference to the key stored in the tree.
Exceptions
std::domain_errorif iv.low > iv.high (invalid interval) or if the interval already exists in the tree.
whatthe comparison or the copy of an endpoint throw, and std::bad_alloc, with the tree as it was.
Note
If an assignment of an endpoint throws when the maxima are given, which only an endpoint whose copy assignment and whose move assignment may throw allows, the maxima of some nodes may be left changed: see Gen_Interval_Tree::insert(). The tree must then be destroyed, or built again from its intervals.

Definition at line 1478 of file tpl_interval_tree.H.

References ah_domain_error, ah_domain_error_if, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::endpoint_comp(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert(), KEY, and Aleph::DynIntervalTree< T, Compare >::tree.

◆ insert_dup()

template<typename T , class Compare = Aleph::less<T>>
Key & Aleph::DynIntervalTree< T, Compare >::insert_dup ( const Key &  iv)
inline

Insert interval, allowing duplicates.

Parameters
[in]ivthe interval to insert.
Returns
reference to the stored key.
Exceptions
std::domain_errorif iv.low > iv.high.
whatthe comparison or the copy of an endpoint throw, and std::bad_alloc, with the tree as it was.
Note
If an assignment of an endpoint throws when the maxima are given, which only an endpoint whose copy assignment and whose move assignment may throw allows, the maxima of some nodes may be left changed: see Gen_Interval_Tree::insert(). The tree must then be destroyed, or built again from its intervals.

Definition at line 1524 of file tpl_interval_tree.H.

References ah_domain_error_if, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::endpoint_comp(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::insert_dup(), Aleph::Interval< T >::is_valid(), KEY, and Aleph::DynIntervalTree< T, Compare >::tree.

Referenced by Aleph::DynIntervalTree< T, Compare >::append(), segment_intersection(), TEST(), and TEST().

◆ is_empty()

template<typename T , class Compare = Aleph::less<T>>
bool Aleph::DynIntervalTree< T, Compare >::is_empty ( ) const
inlinenoexcept

Return true if the tree contains no intervals.

Returns
true if empty.
Exceptions
none

Definition at line 1690 of file tpl_interval_tree.H.

References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::is_empty(), and Aleph::DynIntervalTree< T, Compare >::tree.

Referenced by Aleph::DynIntervalTree< T, Compare >::empty().

◆ key_comp()

template<typename T , class Compare = Aleph::less<T>>
auto Aleph::DynIntervalTree< T, Compare >::key_comp ( ) const
inlinenoexcept

Return the comparator that orders the intervals: by low endpoint, then by high endpoint.

Returns
the interval comparator, which holds a copy of the endpoint comparator.
Exceptions
whatcopying the endpoint comparator throws.

Definition at line 1681 of file tpl_interval_tree.H.

References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::key_comp(), and Aleph::DynIntervalTree< T, Compare >::tree.

◆ operator=() [1/2]

template<typename T , class Compare = Aleph::less<T>>
DynIntervalTree & Aleph::DynIntervalTree< T, Compare >::operator= ( const DynIntervalTree< T, Compare > &  src)
inline

Copy assignment.

Parameters
[in]srcSource tree to copy from.
Returns
Reference to this tree.

Definition at line 1400 of file tpl_interval_tree.H.

References Aleph::DynIntervalTree< T, Compare >::swap().

◆ operator=() [2/2]

template<typename T , class Compare = Aleph::less<T>>
DynIntervalTree & Aleph::DynIntervalTree< T, Compare >::operator= ( DynIntervalTree< T, Compare > &&  src)
inlinenoexcept

Move assignment.

Parameters
[in,out]srcSource tree to move from.
Returns
Reference to this tree.

Definition at line 1413 of file tpl_interval_tree.H.

References Aleph::DynIntervalTree< T, Compare >::destroy_tree(), Aleph::Gen_Interval_Tree< NodeType, T, Compare >::swap(), and Aleph::DynIntervalTree< T, Compare >::tree.

◆ overlap_search() [1/2]

template<typename T , class Compare = Aleph::less<T>>
const Key * Aleph::DynIntervalTree< T, Compare >::overlap_search ( const Key &  query) const
inline

Find any interval overlapping query.

Parameters
[in]querythe query interval.
Returns
pointer to an overlapping interval, or nullptr if none.
Complexity: O(log n) expected.

Definition at line 1598 of file tpl_interval_tree.H.

References KEY, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::overlap_search(), and Aleph::DynIntervalTree< T, Compare >::tree.

Referenced by Aleph::DynIntervalTree< T, Compare >::overlap_search(), TEST(), TEST(), and TEST().

◆ overlap_search() [2/2]

template<typename T , class Compare = Aleph::less<T>>
const Key * Aleph::DynIntervalTree< T, Compare >::overlap_search ( const T &  lo,
const T &  hi 
) const
inline

Overload of overlap_search() using endpoints.

Parameters
[in]lolower endpoint.
[in]hiupper endpoint.
Returns
pointer to an overlapping interval, or nullptr.

Definition at line 1609 of file tpl_interval_tree.H.

References Aleph::DynIntervalTree< T, Compare >::overlap_search().

◆ remove() [1/2]

template<typename T , class Compare = Aleph::less<T>>
bool Aleph::DynIntervalTree< T, Compare >::remove ( const Key &  iv)
inline

Remove an interval from the tree.

Parameters
[in]ivthe interval to remove.
Returns
true if removed, false if not found.
Exceptions
whatthe comparison or the copy of an endpoint throw, with the tree as it was.
Note
If an assignment of an endpoint throws when the maxima are given, which only an endpoint whose copy assignment and whose move assignment may throw allows, the maxima of some nodes may be left changed: see Gen_Interval_Tree::remove(). The tree must then be destroyed, or built again from its intervals.

Definition at line 1558 of file tpl_interval_tree.H.

References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::remove(), and Aleph::DynIntervalTree< T, Compare >::tree.

Referenced by Aleph::DynIntervalTree< T, Compare >::remove(), and TEST().

◆ remove() [2/2]

template<typename T , class Compare = Aleph::less<T>>
bool Aleph::DynIntervalTree< T, Compare >::remove ( const T &  lo,
const T &  hi 
)
inline

Remove an interval given endpoints.

Parameters
[in]lolower endpoint.
[in]hiupper endpoint.
Returns
true if removed, false if not found.

Definition at line 1573 of file tpl_interval_tree.H.

References Aleph::DynIntervalTree< T, Compare >::remove().

◆ search()

template<typename T , class Compare = Aleph::less<T>>
const Key * Aleph::DynIntervalTree< T, Compare >::search ( const Key &  iv) const
inlinenoexcept

Search for an exact interval.

Parameters
[in]ivinterval to search.
Returns
pointer to the stored interval if found, nullptr otherwise.
Exceptions
whatthe comparison or its copy throw; nothing when neither does.

Definition at line 1585 of file tpl_interval_tree.H.

References KEY, Aleph::Gen_Interval_Tree< NodeType, T, Compare >::search(), and Aleph::DynIntervalTree< T, Compare >::tree.

Referenced by TEST(), TEST(), and TEST().

◆ size()

template<typename T , class Compare = Aleph::less<T>>
size_t Aleph::DynIntervalTree< T, Compare >::size ( ) const
inlinenoexcept

Return the number of intervals in the tree.

Returns
number of nodes.
Exceptions
none

Definition at line 1673 of file tpl_interval_tree.H.

References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::size(), and Aleph::DynIntervalTree< T, Compare >::tree.

Referenced by TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ stab()

template<typename T , class Compare = Aleph::less<T>>
template<class Op >
void Aleph::DynIntervalTree< T, Compare >::stab ( const T &  p,
Op &&  op 
) const
inline

Apply op to every interval containing point p.

Template Parameters
OpCallable with signature void(const Key&).
Parameters
[in]pquery point.
[in]opcallable to invoke for each containing interval.
Exceptions
Maythrow if the provided callback throws.

Definition at line 1655 of file tpl_interval_tree.H.

References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::stab(), and Aleph::DynIntervalTree< T, Compare >::tree.

◆ swap()

template<typename T , class Compare = Aleph::less<T>>
void Aleph::DynIntervalTree< T, Compare >::swap ( DynIntervalTree< T, Compare > &  other)
inlinenoexcept

Swap state with another tree in O(1).

Parameters
[in,out]otherThe other tree.

Definition at line 1429 of file tpl_interval_tree.H.

References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::swap(), and Aleph::DynIntervalTree< T, Compare >::tree.

Referenced by Aleph::DynIntervalTree< T, Compare >::DynIntervalTree(), and Aleph::DynIntervalTree< T, Compare >::operator=().

◆ traverse() [1/4]

template<typename T , class Compare = Aleph::less<T>>
template<class Operation >
requires Aleph::PredicateWith<Operation &, const Key &>
bool Aleph::DynIntervalTree< T, Compare >::traverse ( Operation &&  op = Operation())
inline

Overload of traverse() for rvalue callbacks.

Template Parameters
Operationcallable with signature bool(const Key&).
Parameters
[in]opcallable to perform on each interval.
Returns
true if all items were traversed.
Exceptions
anythingthat op throws.

Definition at line 1730 of file tpl_interval_tree.H.

◆ traverse() [2/4]

template<typename T , class Compare = Aleph::less<T>>
template<class Operation >
requires Aleph::PredicateWith<Operation &, const Key &>
bool Aleph::DynIntervalTree< T, Compare >::traverse ( Operation &&  op = Operation()) const
inline

Const rvalue overload of traverse().

Template Parameters
Operationcallable with signature bool(const Key&).
Parameters
[in]opcallable to perform on each interval.
Returns
true if all items were traversed.
Exceptions
anythingthat op throws.

Definition at line 1759 of file tpl_interval_tree.H.

◆ traverse() [3/4]

template<typename T , class Compare = Aleph::less<T>>
template<class Operation >
requires Aleph::PredicateWith<Operation &, const Key &>
bool Aleph::DynIntervalTree< T, Compare >::traverse ( Operation &  op)
inline

Traverse all intervals in inorder (sorted by low endpoint).

If op returns false, traversal stops early.

Template Parameters
Operationcallable with signature bool(const Key&).
Parameters
[in]opcallable to perform on each interval.
Returns
true if all items were traversed.
Exceptions
anythingthat op throws.

Definition at line 1714 of file tpl_interval_tree.H.

References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::getRoot(), Aleph::traverse(), and Aleph::DynIntervalTree< T, Compare >::tree.

◆ traverse() [4/4]

template<typename T , class Compare = Aleph::less<T>>
template<class Operation >
requires Aleph::PredicateWith<Operation &, const Key &>
bool Aleph::DynIntervalTree< T, Compare >::traverse ( Operation &  op) const
inline

Const overload of traverse().

Template Parameters
Operationcallable with signature bool(const Key&).
Parameters
[in]opcallable to perform on each interval.
Returns
true if all items were traversed.
Exceptions
anythingthat op throws.

Definition at line 1743 of file tpl_interval_tree.H.

References Aleph::Gen_Interval_Tree< NodeType, T, Compare >::getRoot(), Aleph::traverse(), and Aleph::DynIntervalTree< T, Compare >::tree.

◆ verify()

template<typename T , class Compare = Aleph::less<T>>
bool Aleph::DynIntervalTree< T, Compare >::verify ( ) const
inline

Verify all tree invariants (BST, Treap, MaxEndpoint).

Returns
true if valid.

Definition at line 1701 of file tpl_interval_tree.H.

References Aleph::DynIntervalTree< T, Compare >::tree, and Aleph::Gen_Interval_Tree< NodeType, T, Compare >::verify().

Referenced by segment_intersection(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

Member Data Documentation

◆ tree


The documentation for this class was generated from the following file: