ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::Joinable< T, A, Key, Value > Class Template Reference

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>

Inheritance diagram for ADS::Joinable< T, A, Key, Value >:
ADS::JoinTree< Interval, std::size_t, WeightBalance, MaxEnd > ADS::JoinTree< Point, std::size_t, WeightBalance, Ordinates > ADS::JoinTree< K, V, AVLBalance, G, Policy, A > ADS::JoinTree< K, V, RedBlackBalance, G, Policy, A > ADS::JoinTree< K, V, WeightBalance, G, Policy, A > ADS::JoinTree< K, V, TreapBalance, G, Policy, A >

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

Detailed description

template<class T, class A, class Key, class Value>
class ADS::Joinable< T, A, Key, Value >

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

Member function documentation

◆ differenceWith() [1/2]

template<class T, class A, class Key, class Value>
template<Executor E>
void ADS::Joinable< T, A, Key, Value >::differenceWith ( E & ex,
T && o )

differenceWith( o ) on the threads of ex

◆ differenceWith() [2/2]

template<class T, class A, class Key, class Value>
void ADS::Joinable< T, A, Key, Value >::differenceWith ( T && o)
inline

the keys not in o, which is consumed, by JoinAlgorithms::subtract(); the work of unionWith(), plus the freeing of the nodes of o

◆ extractRange()

template<class T, class A, class Key, class Value>
T ADS::Joinable< T, A, Key, Value >::extractRange ( const Key & lo,
const Key & hi )
nodiscard

the pairs of the keys in \( [ \mathit{lo} , \mathit{hi} ] \), taken out of the tree by JoinAlgorithms::extract(), in \( O( \log n ) \) time

◆ filter() [1/2]

template<class T, class A, class Key, class Value>
template<Executor E, class P>
void ADS::Joinable< T, A, Key, Value >::filter ( E & ex,
P p )

filter( p ) on the threads of ex

◆ filter() [2/2]

template<class T, class A, class Key, class Value>
template<class P>
void ADS::Joinable< T, A, Key, Value >::filter ( P p)
inline

only the pairs with p( k , v ) kept, by JoinAlgorithms::filter(), \( O( n ) \) work

◆ intersectWith() [1/2]

template<class T, class A, class Key, class Value>
template<Executor E, class F = TakeFirst>
void ADS::Joinable< T, A, Key, Value >::intersectWith ( E & ex,
T && o,
F f = F() )

intersectWith( o , f ) on the threads of ex

◆ intersectWith() [2/2]

template<class T, class A, class Key, class Value>
template<class F = TakeFirst>
void ADS::Joinable< T, A, Key, Value >::intersectWith ( T && o,
F f = F() )
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

◆ join()

template<class T, class A, class Key, class Value>
T ADS::Joinable< T, A, Key, Value >::join ( T && l,
const Key & k,
const Value & v,
T && r )
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

Precondition
the keys of \( l \) are smaller than \( k \), those of \( r \) larger

◆ join2()

template<class T, class A, class Key, class Value>
T ADS::Joinable< T, A, Key, Value >::join2 ( T && l,
T && r )
staticnodiscard

the tree of the keys of \( l \) and of \( r \), which are consumed, by JoinAlgorithms::join2(), in \( O( \log n ) \) time

Precondition
the keys of \( l \) are smaller than those of \( r \)

◆ mapReduce() [1/2]

template<class T, class A, class Key, class Value>
template<Executor E, class M, class R, class U>
U ADS::Joinable< T, A, Key, Value >::mapReduce ( E & ex,
M map,
R reduce,
U id ) const
nodiscard

mapReduce( map , reduce , id ) on the threads of ex

◆ mapReduce() [2/2]

template<class T, class A, class Key, class Value>
template<class M, class R, class U>
U ADS::Joinable< T, A, Key, Value >::mapReduce ( M map,
R reduce,
U id ) const
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

◆ multiInsert() [1/2]

template<class T, class A, class Key, class Value>
template<Executor E, class F = TakeSecond>
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

◆ multiInsert() [2/2]

template<class T, class A, class Key, class Value>
template<class F = TakeSecond>
void ADS::Joinable< T, A, Key, Value >::multiInsert ( std::span< const std::pair< Key, Value > > B,
F f = F() )
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

Precondition
the keys of \( B \) increasing (an audit)

◆ multiRemove() [1/2]

template<class T, class A, class Key, class Value>
template<Executor E>
void ADS::Joinable< T, A, Key, Value >::multiRemove ( E & ex,
std::span< const Key > B )

multiRemove( B ) on the threads of ex

◆ multiRemove() [2/2]

template<class T, class A, class Key, class Value>
void ADS::Joinable< T, A, Key, Value >::multiRemove ( std::span< const Key > B)
inline

the keys of \( B \) removed, by JoinAlgorithms::multiRemove(), \( O( m \log( n / m + 1 ) ) \) work

Precondition
the keys of \( B \) increasing (an audit)

◆ split()

template<class T, class A, class Key, class Value>
std::tuple< T, std::optional< Value >, T > ADS::Joinable< T, A, Key, Value >::split ( const Key & k) &&
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

◆ unionWith() [1/2]

template<class T, class A, class Key, class Value>
template<Executor E, class F = TakeSecond>
void ADS::Joinable< T, A, Key, Value >::unionWith ( E & ex,
T && o,
F f = F() )

unionWith( o , f ) on the threads of ex

◆ unionWith() [2/2]

template<class T, class A, class Key, class Value>
template<class F = TakeSecond>
void ADS::Joinable< T, A, Key, Value >::unionWith ( T && o,
F f = F() )
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 \)


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