54#ifndef __ADS_MaterializedAggregate
55 #define __ADS_MaterializedAggregate
87 template<
class A ,
class B >
88 void operator()(
const A & ,
const B & )
const { }
93concept pair_visitable =
requires(
const S & s )
94{ s.forEach( AnyPair() ); };
106template<
class G , std::
size_t Period = 1024 >
132 template< detail::pair_visitable S >
139 template< detail::pair_visitable S >
168 template<
class H ,
class K ,
class V >
191 template<
class H ,
class K ,
class V >
216 template<
class H ,
class V >
251 [[nodiscard]]
bool stale(
void )
const {
return( f_stale ); }
254 [[nodiscard]]
bool bound(
void )
const {
return( f_src !=
nullptr ); }
258 return( f_recomputed );
264 template< detail::pair_visitable S >
265 [[nodiscard]]
bool audit(
const S & s )
const;
273 bool operator()(
const Value & x ,
const Value & y )
const {
274 return( ! ( x == y ) && ( G::combine( x , y ) == x ) );
282 std::multiset< Value , Before > , NoSet >;
285 void changed(
void )
noexcept;
288 void recompute(
void )
const;
292 static Value fold(
const S & s );
294 mutable Value f_a = G::identity();
296 mutable bool f_stale =
false;
297 mutable std::size_t f_drift = 0;
298 mutable std::size_t f_recomputed = 0;
299 const void * f_src =
nullptr;
313#include "ADS/tree/impl/MaterializedAggregate.tpp"
The algebra of the aggregates, beyond the book: the concepts by which a structure that keeps a combin...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The binary search trees balanced by join alone, and the augmented maps, beyond the book: JoinTree< K ...
The typed modifications, beyond the book: the vocabulary by which a structure tells the observers att...
MaterializedAggregate(void)=default
the identity, with no structure bound
bool audit(const S &s) const
whether the aggregate (if not stale) is that of : equal for exact values, within a relative tolerance...
Value value(void) const
the aggregate, recomputed from the structure bound if stale
void bind(const S &s)
bound, and the aggregate recomputed from it, in ( if selective)
Kind
how the events update the aggregate
Definition MaterializedAggregate.h:116
@ Group
by the value and its inverse
Definition MaterializedAggregate.h:117
@ Selective
by the multiset of the values
Definition MaterializedAggregate.h:118
static constexpr Kind kind
the kind of G
Definition MaterializedAggregate.h:123
void on(const mod::Assigned< H, V > &e)
the value of the key changed from to : , or the two values exchanged in the multiset,...
bool stale(void) const
whether the next value() recomputes
Definition MaterializedAggregate.h:251
void on(const mod::Cleared &) noexcept
the structure emptied: the identity
void on(const mod::Rebuilt &) noexcept
anything may have changed: the aggregate stale
Definition MaterializedAggregate.h:223
bool bound(void) const
whether a structure is bound
Definition MaterializedAggregate.h:254
MaterializedAggregate(const S &s)
the aggregate of , bound
Definition MaterializedAggregate.h:133
void on(const mod::Erased< H, K, V > &e) noexcept
the pair erased: , or the value taken out of the multiset, or the aggregate stale
typename G::Value Value
the type of the aggregate
Definition MaterializedAggregate.h:113
std::size_t recomputations(void) const
the recomputations made so far
Definition MaterializedAggregate.h:257
void on(const mod::Inserted< H, K, V > &e)
the pair inserted: , or the value added to the multiset
a group whose operation commutes
Definition Algebra.h:137
a monoid whose operation commutes, by the opt-in G::commutative
Definition Algebra.h:125
a monoid with the inverse G::inverse( a ), i.e., combine( inverse( a) , a ) and combine( a ,...
Definition Algebra.h:130
a monoid on G::Value: the identity G::identity() and the associative operation G::combine( a ,...
Definition Algebra.h:117
a monoid whose combine( a , b ) is always or , by the opt-in G::selective
Definition Algebra.h:142
Changed< Value, H, V > Assigned
the value of an item changed
Definition Modification.h:623
#define ADS_NO_UNIQUE_ADDRESS
an empty member that takes no storage, by the attribute that does so (the standard one is accepted bu...
Definition Portable.h:81
the structure emptied
Definition Modification.h:699
the item of handle , key and value erased, told before the removal outside a batch
Definition Modification.h:568
the item of handle , key and value inserted
Definition Modification.h:536
anything may have changed: forget and recompute
Definition Modification.h:708