|
ADS
Algorithms and Data Structures
|
the operations based on join of the tree T of keys Key and values Value, whose nodes A adapts [see JoinAdaptor], each the function of JoinAlgorithms of the same name: a base of T (which makes A its friend); A is read only in the bodies, as T is incomplete where its bases are named, and gives take( t ), the root of \( t \) taken out of it, which is left empty; put( t , r ), \( r \) the new root of the empty \( t \), which updates its size; peek( t ), its root; fresh( t ), an empty tree like \( t \); valid( t ), the invariant of \( t \); salt( t ) and make( k , v , s , i ), a node alone of the pair \( ( k , v ) \), the \( i \)-th of a batch of salt \( s \), which may be called in parallel More...
#include <ADS/tree/JoinAlgorithms.h>
Public member functions | |
| std::tuple< T, std::optional< Value >, T > | split (const Key &k) && |
| the keys before \( k \), the value of \( k \) (if there), the keys after \( k \), by JoinAlgorithms::split(); the tree is consumed, in \( O( \log n ) \) time | |
| T | extractRange (const Key &lo, const Key &hi) |
| the pairs of the keys in \( [ \mathit{lo} , \mathit{hi} ] \), taken out of the tree by JoinAlgorithms::extract(), in \( O( \log n ) \) time | |
| template<class F = TakeSecond> | |
| void | unionWith (T &&o, F f=F()) |
| the union with o, which is consumed, by JoinAlgorithms::unite(); on a key of both, the value f( mine , its ), by default its; \( O( m \log( n / m + 1 ) ) \) work for sizes \( m \le n \) | |
| template<Executor E, class F = TakeSecond> | |
| void | unionWith (E &ex, T &&o, F f=F()) |
| unionWith( o , f ) on the threads of ex | |
| template<class F = TakeFirst> | |
| void | intersectWith (T &&o, F f=F()) |
| the intersection with o, which is consumed, by JoinAlgorithms::intersect(); the value f( mine , its ), by default mine; the work of unionWith(), plus the freeing of the nodes that leave | |
| template<Executor E, class F = TakeFirst> | |
| void | intersectWith (E &ex, T &&o, F f=F()) |
| intersectWith( o , f ) on the threads of ex | |
| void | differenceWith (T &&o) |
| the keys not in o, which is consumed, by JoinAlgorithms::subtract(); the work of unionWith(), plus the freeing of the nodes of o | |
| template<Executor E> | |
| void | differenceWith (E &ex, T &&o) |
| differenceWith( o ) on the threads of ex | |
| template<class F = TakeSecond> | |
| void | multiInsert (std::span< const std::pair< Key, Value > > B, F f=F()) |
| the pairs of \( B \) inserted, by JoinAlgorithms::multiInsert(); on a key already there, the value f( mine , new ), by default new; \( O( m \log( n / m + 1 ) ) \) work for \( m \) pairs | |
| template<Executor E, class F = TakeSecond> | |
| void | multiInsert (E &ex, std::span< const std::pair< Key, Value > > B, F f=F()) |
| multiInsert( B , f ) on the threads of ex | |
| void | multiRemove (std::span< const Key > B) |
| the keys of \( B \) removed, by JoinAlgorithms::multiRemove(), \( O( m \log( n / m + 1 ) ) \) work | |
| template<Executor E> | |
| void | multiRemove (E &ex, std::span< const Key > B) |
| multiRemove( B ) on the threads of ex | |
| template<class P> | |
| void | filter (P p) |
| only the pairs with p( k , v ) kept, by JoinAlgorithms::filter(), \( O( n ) \) work | |
| template<Executor E, class P> | |
| void | filter (E &ex, P p) |
| filter( p ) on the threads of ex | |
| template<class M, class R, class U> | |
| U | mapReduce (M map, R reduce, U id) const |
| \( \mathrm{reduce}( \ldots \mathrm{reduce}( \mathit{id} , \mathrm{map}(
k_1 , v_1 ) ) \ldots , \mathrm{map}( k_n , v_n ) ) \) by an associative reduce of identity id, by JoinAlgorithms::mapReduce(), \( O( n ) \) work | |
| template<Executor E, class M, class R, class U> | |
| U | mapReduce (E &ex, M map, R reduce, U id) const |
| mapReduce( map , reduce , id ) on the threads of ex | |
Static public member functions | |
| static T | join (T &&l, const Key &k, const Value &v, T &&r) |
| the tree of the keys of \( l \), the pair \( ( k , v ) \) and the keys of \( r \), by the join of the scheme; \( l \) and \( r \) are consumed, in \( O( | \log n_l - \log n_r | + 1 ) \) time | |
| static T | join2 (T &&l, T &&r) |
| the tree of the keys of \( l \) and of \( r \), which are consumed, by JoinAlgorithms::join2(), in \( O( \log n ) \) time | |
the operations based on join of the tree T of keys Key and values Value, whose nodes A adapts [see JoinAdaptor], each the function of JoinAlgorithms of the same name: a base of T (which makes A its friend); A is read only in the bodies, as T is incomplete where its bases are named, and gives take( t ), the root of \( t \) taken out of it, which is left empty; put( t , r ), \( r \) the new root of the empty \( t \), which updates its size; peek( t ), its root; fresh( t ), an empty tree like \( t \); valid( t ), the invariant of \( t \); salt( t ) and make( k , v , s , i ), a node alone of the pair \( ( k , v ) \), the \( i \)-th of a batch of salt \( s \), which may be called in parallel
| void ADS::Joinable< T, A, Key, Value >::differenceWith | ( | E & | ex, |
| T && | o ) |
differenceWith( o ) on the threads of ex
|
inline |
the keys not in o, which is consumed, by JoinAlgorithms::subtract(); the work of unionWith(), plus the freeing of the nodes of o
|
nodiscard |
the pairs of the keys in \( [ \mathit{lo} , \mathit{hi} ] \), taken out of the tree by JoinAlgorithms::extract(), in \( O( \log n ) \) time
| void ADS::Joinable< T, A, Key, Value >::filter | ( | E & | ex, |
| P | p ) |
filter( p ) on the threads of ex
|
inline |
only the pairs with p( k , v ) kept, by JoinAlgorithms::filter(), \( O( n ) \) work
| void ADS::Joinable< T, A, Key, Value >::intersectWith | ( | E & | ex, |
| T && | o, | ||
| F | f = F() ) |
intersectWith( o , f ) on the threads of ex
|
inline |
the intersection with o, which is consumed, by JoinAlgorithms::intersect(); the value f( mine , its ), by default mine; the work of unionWith(), plus the freeing of the nodes that leave
|
staticnodiscard |
the tree of the keys of \( l \), the pair \( ( k , v ) \) and the keys of \( r \), by the join of the scheme; \( l \) and \( r \) are consumed, in \( O( | \log n_l - \log n_r | + 1 ) \) time
|
staticnodiscard |
the tree of the keys of \( l \) and of \( r \), which are consumed, by JoinAlgorithms::join2(), in \( O( \log n ) \) time
|
nodiscard |
mapReduce( map , reduce , id ) on the threads of ex
|
inlinenodiscard |
\( \mathrm{reduce}( \ldots \mathrm{reduce}( \mathit{id} , \mathrm{map}( k_1 , v_1 ) ) \ldots , \mathrm{map}( k_n , v_n ) ) \) by an associative reduce of identity id, by JoinAlgorithms::mapReduce(), \( O( n ) \) work
| void ADS::Joinable< T, A, Key, Value >::multiInsert | ( | E & | ex, |
| std::span< const std::pair< Key, Value > > | B, | ||
| F | f = F() ) |
multiInsert( B , f ) on the threads of ex
|
inline |
the pairs of \( B \) inserted, by JoinAlgorithms::multiInsert(); on a key already there, the value f( mine , new ), by default new; \( O( m \log( n / m + 1 ) ) \) work for \( m \) pairs
| void ADS::Joinable< T, A, Key, Value >::multiRemove | ( | E & | ex, |
| std::span< const Key > | B ) |
multiRemove( B ) on the threads of ex
|
inline |
the keys of \( B \) removed, by JoinAlgorithms::multiRemove(), \( O( m \log( n / m + 1 ) ) \) work
|
nodiscard |
the keys before \( k \), the value of \( k \) (if there), the keys after \( k \), by JoinAlgorithms::split(); the tree is consumed, in \( O( \log n ) \) time
| void ADS::Joinable< T, A, Key, Value >::unionWith | ( | E & | ex, |
| T && | o, | ||
| F | f = F() ) |
unionWith( o , f ) on the threads of ex
|
inline |
the union with o, which is consumed, by JoinAlgorithms::unite(); on a key of both, the value f( mine , its ), by default its; \( O( m \log( n / m + 1 ) ) \) work for sizes \( m \le n \)