|
ADS
Algorithms and Data Structures
|
The interval tree as an augmented map, beyond the book: a multiset of closed intervals \( [ a , b ] \) of a totally ordered type, kept in a map [see JoinTree.h] whose keys are the pairs \( ( a , b ) \) in lexicographic order, whose values are their multiplicities, and whose augmentation is the largest right end of the subtree, \( \mathit{aug}( u ) = \max \{ b : ( a , b ) \in T_u \} \), the monoid of the maximum on the right ends, whose identity is no interval. More...
#include "ADS/Contract.h"#include "ADS/parallel/Executor.h"#include "ADS/tree/JoinTree.h"#include <concepts>#include <cstddef>#include <optional>#include <utility>#include <vector>#include "ADS/geometry/impl/IntervalTree.tpp"Go to the source code of this file.
Classes | |
| class | ADS::IntervalTree< T > |
| a multiset of closed intervals of T with stabbing queries More... | |
| struct | ADS::IntervalTree< T >::MaxEnd |
| the augmentation: the largest right end, nothing for no interval More... | |
Namespaces | |
| namespace | ADS |
The interval tree as an augmented map, beyond the book: a multiset of closed intervals \( [ a , b ] \) of a totally ordered type, kept in a map [see JoinTree.h] whose keys are the pairs \( ( a , b ) \) in lexicographic order, whose values are their multiplicities, and whose augmentation is the largest right end of the subtree, \( \mathit{aug}( u ) = \max \{ b : ( a , b ) \in T_u \} \), the monoid of the maximum on the right ends, whose identity is no interval.
The map is balanced by weight, and the augmentation is kept by its join alone, as for every augmented map.
A stabbing query asks for the intervals that contain a point \( x \). The intervals with \( a \le x \) are the keys up to \( ( x , \infty ) \), a prefix of the order, and \( x \) is in one of them if and only if the largest right end of the prefix is at least \( x \); stabbed( x ) reads that maximum on the path that separates the prefix from the rest, combining the augmented values of the left subtrees that the path leaves behind, in \( O( \log n ) \) time. stab( x , f ) reports them all by a visit that enters a subtree only if its augmented value is at least \( x \) and, for a node with \( a > x \), does not enter its right subtree: each node visited either is reported, or lies on one of the paths that lead to the reported ones, so that the visit costs \( O( \min( n , ( k + 1 ) \log n ) ) \) for \( k \) intervals reported. The intervals are inserted and removed one at a time in \( O( \log n ) \), and the constructor takes them all by multiInsert() [see JoinAlgorithms.h], on the threads of an executor if given one.
The contracts [see Contract.h]: \( a \le b \) for each interval; the invariant is that of the map, the largest right ends included. The operations are defined in IntervalTree.tpp.