ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::FenwickObserver< G > Class Template Reference

the prefix aggregates of the values of an array of values of G that tells its changes [see ObservableArray], a Fenwick< G > kept by its events More...

#include <ADS/sequence/Fenwick.h>

Public types

using Assign = mod::Assigned< std::size_t , Value >
 a value written
using Insert = mod::Inserted< std::size_t , std::size_t , Value >
 a value appended
using Erase = mod::Erased< std::size_t , std::size_t , Value >
 the last value removed

Public member functions

 FenwickObserver (void)=default
 an observer of no array, given one later by rebuild()
template<class A>
requires requires( const A & a ) { { a.values() } -> std::same_as< const std::vector< Value > & >; }
 FenwickObserver (const A &a)
 the observer of the array \( a \), its tree built from it
template<class A>
requires requires( const A & a ) { { a.values() } -> std::same_as< const std::vector< Value > & >; }
void rebuild (const A &a)
 the tree built again from the array \( a \), whose vector of values a.values() it reads from now on when Rebuilt comes
void on (const Assign &e)
 \( a_h \gets \mathit{to} \)
void on (const Insert &e)
 the value appended
void on (const Erase &) noexcept
 the last value removed
void on (const mod::Cleared &) noexcept
 no value
void on (const mod::Rebuilt &) noexcept
 the tree forgotten, built again at the next query
void flush (void) const
 the tree built again if Rebuilt came
std::size_t size (void) const
 the number of values
Value prefix (std::size_t r) const
 the prefix \( \pi_r \) [see Fenwick::prefix()]
Value range (std::size_t l, std::size_t r) const
 the range \( a_l \oplus \cdots \oplus a_{r-1} \)
const Fenwick< G > & tree (void) const
 the tree
template<class A>
bool audit (const A &a) const
 whether the tree has the values of the array \( a \) and, when they are exact, its prefixes are those of a scan of \( a \)

Detailed description

template<Monoid G>
class ADS::FenwickObserver< G >

the prefix aggregates of the values of an array of values of G that tells its changes [see ObservableArray], a Fenwick< G > kept by its events

Member typedef documentation

◆ Assign

template<Monoid G>
using ADS::FenwickObserver< G >::Assign = mod::Assigned< std::size_t , Value >

a value written

◆ Erase

template<Monoid G>
using ADS::FenwickObserver< G >::Erase = mod::Erased< std::size_t , std::size_t , Value >

the last value removed

◆ Insert

template<Monoid G>
using ADS::FenwickObserver< G >::Insert = mod::Inserted< std::size_t , std::size_t , Value >

a value appended

Constructor and destructor documentation

◆ FenwickObserver() [1/2]

template<Monoid G>
ADS::FenwickObserver< G >::FenwickObserver ( void )
default

an observer of no array, given one later by rebuild()

◆ FenwickObserver() [2/2]

template<Monoid G>
template<class A>
requires requires( const A & a ) { { a.values() } -> std::same_as< const std::vector< Value > & >; }
ADS::FenwickObserver< G >::FenwickObserver ( const A & a)
inlineexplicit

the observer of the array \( a \), its tree built from it

Member function documentation

◆ audit()

template<Monoid G>
template<class A>
bool ADS::FenwickObserver< G >::audit ( const A & a) const
nodiscard

whether the tree has the values of the array \( a \) and, when they are exact, its prefixes are those of a scan of \( a \)

◆ flush()

template<Monoid G>
void ADS::FenwickObserver< G >::flush ( void ) const
inline

the tree built again if Rebuilt came

◆ on() [1/5]

template<Monoid G>
void ADS::FenwickObserver< G >::on ( const Assign & e)
inline

\( a_h \gets \mathit{to} \)

◆ on() [2/5]

template<Monoid G>
void ADS::FenwickObserver< G >::on ( const Erase & )
inlinenoexcept

the last value removed

◆ on() [3/5]

template<Monoid G>
void ADS::FenwickObserver< G >::on ( const Insert & e)
inline

the value appended

◆ on() [4/5]

template<Monoid G>
void ADS::FenwickObserver< G >::on ( const mod::Cleared & )
inlinenoexcept

no value

◆ on() [5/5]

template<Monoid G>
void ADS::FenwickObserver< G >::on ( const mod::Rebuilt & )
inlinenoexcept

the tree forgotten, built again at the next query

◆ prefix()

template<Monoid G>
Value ADS::FenwickObserver< G >::prefix ( std::size_t r) const
inlinenodiscard

the prefix \( \pi_r \) [see Fenwick::prefix()]

Precondition
\( r \le n \)

◆ range()

template<Monoid G>
Value ADS::FenwickObserver< G >::range ( std::size_t l,
std::size_t r ) const
inlinenodiscard

the range \( a_l \oplus \cdots \oplus a_{r-1} \)

Precondition
\( l \le r \le n \)

◆ rebuild()

template<Monoid G>
template<class A>
requires requires( const A & a ) { { a.values() } -> std::same_as< const std::vector< Value > & >; }
void ADS::FenwickObserver< G >::rebuild ( const A & a)
inline

the tree built again from the array \( a \), whose vector of values a.values() it reads from now on when Rebuilt comes

◆ size()

template<Monoid G>
std::size_t ADS::FenwickObserver< G >::size ( void ) const
inlinenodiscard

the number of values

◆ tree()

template<Monoid G>
const Fenwick< G > & ADS::FenwickObserver< G >::tree ( void ) const
inlinenodiscard

the tree


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