116#ifndef __ADS_Modification
117 #define __ADS_Modification
138#include <type_traits>
163 using std::runtime_error::runtime_error;
224 requires( P & p ,
const ReoptStats & s ,
int outcome ,
double w )
226 { p.scratch( s ) } -> std::convertible_to< bool >;
227 { p.abandon( s , w ) } -> std::convertible_to< bool >;
228 p.record( outcome , w );
255 const std::size_t n = s.
size > 1 ? s.
size : 1;
256 return(
double( s.
events ) >
rho *
double( n ) );
273 [[nodiscard]]
bool refresh( std::size_t c , std::size_t n )
const {
274 const std::size_t m = n > 1 ? n : 1;
275 return( (
period > 0 ) && (
double( c ) >=
period *
double( m ) ) );
305 if constexpr( std::is_floating_point_v< T > )
308 const T as = f_s < T() ? -f_s : f_s;
309 const T ax = x < T() ? -x : x;
310 f_c += as >= ax ? ( f_s - t ) + x : ( x - t ) + f_s;
319 if constexpr( std::is_floating_point_v< T > )
328 [[nodiscard]] T
value(
void )
const {
329 if constexpr( std::is_floating_point_v< T > )
364 static constexpr unsigned grows = 1u;
366 static constexpr unsigned up = 4u;
367 static constexpr unsigned down = 8u;
368 static constexpr unsigned all = 15u;
392constexpr Role declared_role(
void )
394 if constexpr(
requires { E::role; } )
397 return( Role::Other );
401constexpr unsigned declared_effects(
void )
403 if constexpr(
requires { E::effects; } )
404 return(
unsigned( E::effects ) );
406 return( effect::all );
418inline constexpr unsigned effects_of = detail::declared_effects< E >();
473 requires requires {
typename A::reduction; }
476 using type =
typename A::reduction;
480template<
class... E >
483 static constexpr std::size_t
size =
sizeof...( E );
490template<
class E ,
class L >
493template<
class E ,
class... T >
494struct index_in< E ,
list< T... > >
496 static constexpr std::size_t value = [] {
497 constexpr bool same[] = { std::is_same_v< E , T >... ,
false };
499 while( ( i <
sizeof...( T ) ) && ! same[ i ] )
508template<
class... T >
509struct variant_of< list< T... > >
511 using type = std::variant< T... >;
518template<
class E ,
class L >
519inline constexpr std::size_t
index_v = detail::index_in< E , L >::value;
522template<
class E ,
class L >
527using variant_t =
typename detail::variant_of< L >::type;
534template<
class H ,
class K ,
class V =
void >
550template<
class H ,
class K >
566template<
class H ,
class K ,
class V =
void >
582template<
class H ,
class K >
598template<
class A ,
class H ,
class V >
611 [[nodiscard]]
constexpr unsigned direction(
void )
const {
612 if constexpr( std::totally_ordered< V > )
622template<
class H ,
class V >
626template<
class H ,
class K >
658 std::span< const H >
hs;
667 std::span< const H >
hs;
671template<
class A ,
class D >
679 [[nodiscard]]
constexpr unsigned direction(
void )
const {
720template<
class H ,
class K ,
class V >
724 if constexpr( std::is_void_v< V > )
731template<
class H ,
class K ,
class V >
732[[nodiscard]]
constexpr Inserted< H , K , V >
735 if constexpr( std::is_void_v< V > )
742template<
class A ,
class H ,
class V >
743[[nodiscard]]
constexpr Changed< A , H , V >
757template<
class A ,
class D >
777 std::uint64_t
to = 0;
794template<
class O ,
class E >
799template<
class O ,
class E >
801 requires( O & o , std::span< const E > s )
810 } ||
requires( O & o )
817template<
class O ,
class E >
818concept refuses =
requires(
const O & o ,
const E & e )
820 { o.prepare( e ) } -> std::same_as< bool >;
824template<
class O ,
class S >
825concept auditable =
requires(
const O & o ,
const S & s )
827 { o.audit( s ) } -> std::convertible_to< bool >;
832concept lazy =
requires( O & o )
848 { o.reoptStats( k ) } -> std::convertible_to< ReoptStats >;
856 { o.mask() } -> std::convertible_to< std::uint64_t >;
863template<
class O ,
class L >
866template<
class O ,
class... E >
867struct any_observed< O ,
list< E... > >
876template<
class O ,
class L >
889 template<
class O ,
class E >
891 static decltype( auto )
one( O & o ,
892 const E & e )
noexcept(
noexcept( o.on( e ) ) ) {
896 template<
class O ,
class E >
898 static void many( O & o , std::span< const E > s ) {
905 if constexpr(
requires { o.group_begin( g ); } )
913 static void end( O & o ) {
917 template<
class O ,
class E >
919 static bool prepare(
const O & o ,
const E & e ) {
920 return( o.prepare( e ) );
923 template<
class O ,
class S >
925 static bool audit(
const O & o ,
const S & s ) {
926 return(
bool( o.audit( s ) ) );
931 static std::uint64_t
mask(
const O & o ) {
932 return( std::uint64_t( o.mask() ) );
938 static bool early( O & o , std::size_t k ) {
941 return(
bool( o.policy().scratch( s ) ) );
952template<
class O ,
class A = Direct >
971 static std::vector< variant_t< L > >
991template<
class O ,
class A >
992struct held< Via< O , A > >
999template<
class A ,
class O ,
class E >
1000concept calls =
requires( O & o ,
const E & e )
1001{ A::one( o , e ); };
1004template<
class A ,
class O ,
class E >
1005inline constexpr bool calls_keep = [] {
1006 if constexpr( calls< A , O , E > )
1007 return( std::same_as<
decltype( A::one( std::declval< O & >() ,
1008 std::declval< const E & >() ) ) ,
1015template<
class A ,
class O ,
class E >
1016inline constexpr bool calls_nothrow = [] {
1017 if constexpr( calls< A , O , E > )
1019 noexcept( A::one( std::declval< O & >() ,
1020 std::declval< const E & >() ) ) );
1026template<
class A ,
class O ,
class E >
1028 requires( O & o , std::span< const E > s )
1029{ A::many( o , s ); };
1032template<
class A ,
class O >
1033concept calls_group =
requires( O & o ,
const Group & g )
1040template<
class A ,
class O ,
class E >
1041concept calls_prepare =
requires(
const O & o ,
const E & e )
1043 { A::prepare( o , e ) } -> std::same_as< bool >;
1047template<
class A ,
class O ,
class S >
1048concept calls_audit =
requires(
const O & o ,
const S & s )
1050 { A::audit( o , s ) } -> std::convertible_to< bool >;
1054template<
class A ,
class O >
1055concept calls_mask =
requires(
const O & o )
1057 { A::mask( o ) } -> std::convertible_to< std::uint64_t >;
1061template<
class A ,
class O >
1062concept calls_policy =
requires( O & o , std::size_t k )
1064 { A::early( o , k ) } -> std::same_as< bool >;
1069template<
class Var >
1070std::size_t eventsFor( std::span< const Var > C , std::uint64_t m ,
bool all )
1075 for(
const auto & e : C )
1076 k += std::size_t( ( m >> e.index() ) & 1u );
1081template<
class A ,
class O ,
class L >
1084template<
class A ,
class O ,
class... E >
1085struct kinds_of< A , O , list< E... > >
1087 static constexpr std::uint64_t value = [] {
1088 std::uint64_t m = 0;
1090 ( ( m |= ( calls< A , O , E > ? ( std::uint64_t( 1 ) << i ) : 0 ) , ++i ) ,
1094 static constexpr bool keep = ( calls_keep< A , O , E > || ... );
1095 static constexpr bool nothrow_ok =
1096 ( ( ! must_not_throw< E > || calls_nothrow< A , O , E > ) && ... );
1100template<
class R ,
class L >
1103template<
class... R ,
class L >
1104struct all_in< list< R... > , L >
1106 static constexpr bool value = ( contains_v< R , L > && ... );
1113 using type = list<>;
1117 requires requires {
typename O::requires_modifications; }
1120 using type =
typename O::requires_modifications;
1125template<
class A ,
class O ,
class L >
1126constexpr void check(
void )
1128 static_assert( kinds_of< A , O , L >::value != 0 ,
1129 "ADS: the observer has an on() for none of the events of "
1131 static_assert( all_in< typename required< O >::type , L >::value ,
1132 "ADS: the observer requires an event that the structure "
1134 static_assert( kinds_of< A , O , L >::nothrow_ok ,
1135 "ADS: on() of Erased, BulkErased, Cleared, Rebuilt and "
1136 "Replaced must be noexcept" );
1140template<
class L ,
class F >
1141void visitKind( std::size_t k , F && f );
1145template<
class A ,
class O ,
class E ,
class Var >
1146bool giveRun( O & o , std::span< const Var > R );
1152 [[nodiscard]]
constexpr bool off( std::size_t )
const {
return(
false ); }
1153 constexpr void set( std::size_t ) { }
1157struct OffBits< true >
1159 std::uint64_t bits = 0;
1160 [[nodiscard]]
bool off( std::size_t i )
const {
1161 return( ( bits >> i ) & 1u );
1163 void set( std::size_t i ) { bits |= std::uint64_t( 1 ) << i; }
1168template< std::
size_t N ,
bool B = ( ADS_CONTRACTS >= 3 ) >
1171 [[nodiscard]]
static Counts at( std::size_t ) {
return( Counts() ); }
1172 static void event( std::size_t ) { }
1173 static void group( std::size_t ) { }
1174 static void rebuild( std::size_t ) { }
1177template< std::
size_t N >
1178struct StaticCounts< N , true >
1180 std::array< Counts , N > c{};
1181 [[nodiscard]] Counts at( std::size_t i )
const {
return( c[ i ] ); }
1182 void event( std::size_t i ) { ++c[ i ].events; }
1183 void group( std::size_t i ) { ++c[ i ].groups; }
1184 void rebuild( std::size_t i ) { ++c[ i ].rebuilds; }
1191 std::uint64_t st = 0;
1200 static constexpr bool listened =
false;
1201 template<
class... A >
1202 constexpr explicit NoStatic( A &... ) {
1203 static_assert(
sizeof...( A ) == 0 ,
1204 "ADS: observers given to a subject with no static part" );
1207 [[nodiscard]]
constexpr bool live(
void )
const {
1210 [[nodiscard]]
constexpr std::uint64_t wanted(
void )
const {
return( 0 ); }
1211 template<
class E ,
bool T >
1212 constexpr void deliver(
const E & , Trail & ) { }
1213 template<
class E ,
class Inv >
1214 constexpr void undo(
const Inv & ,
const Trail & )
noexcept { }
1216 [[nodiscard]]
constexpr bool prepare(
const E & )
const {
1220 [[nodiscard]]
constexpr bool audit(
const S & )
const {
1223 template<
class Var >
1224 constexpr void deliverGroup( std::span< const Var > , std::uint64_t ,
1225 const Group & , std::vector< Var > & ) { }
1230template<
class L ,
class Obs ,
class... X >
1234 static constexpr std::size_t N =
sizeof...( X );
1235 using Objects = std::tuple< typename held< X >::object &... >;
1236 template< std::
size_t I >
1237 using Xi = std::tuple_element_t< I , std::tuple< X... > >;
1238 template< std::
size_t I >
1239 using Oi =
typename held< Xi< I > >::object;
1240 template< std::
size_t I >
1241 using Ai =
typename held< Xi< I > >::adapter;
1243 static constexpr bool may_leave =
1244 ( kinds_of< typename held< X >::adapter ,
typename held< X >::object ,
1250 static constexpr bool listened =
1251 ( calls< typename held< X >::adapter ,
typename held< X >::object , E > ||
1254 template<
class... A >
1255 explicit StaticSet( A &... a ) : f_o( a... ) {
1256 static_assert( N <= 64 ,
"ADS: at most 64 static observers" );
1257 ( check< typename held< X >::adapter ,
typename held< X >::object , L >() ,
1259 checkOrder( std::make_index_sequence< N >() );
1263 template< std::
size_t I ,
class E >
1264 [[nodiscard]]
bool wants(
void )
const {
1265 if constexpr( ! calls< Ai< I > , Oi< I > , E > )
1269 if constexpr( calls_mask< Ai< I > , Oi< I > > )
1270 w = ( Ai< I >::mask( std::get< I >( f_o ) ) >> index_v< E , L > )&1u;
1271 if constexpr( may_leave )
1272 w = w && ! f_off.off( I );
1278 [[nodiscard]]
bool live(
void )
const {
1279 return( [ & ]< std::size_t... I >( std::index_sequence< I... > ) {
1280 return( ( wants< I , E >() || ... ) );
1281 }( std::make_index_sequence< N >() ) );
1285 [[nodiscard]] std::uint64_t wanted(
void )
const {
1286 return( [ & ]< std::size_t... I >( std::index_sequence< I... > ) {
1287 return( ( wantedBy< I >() | ... | std::uint64_t( 0 ) ) );
1288 }( std::make_index_sequence< N >() ) );
1291 template<
class E ,
bool T >
1292 void deliver(
const E & e , Trail & t ) {
1293 [ & ]< std::size_t... I >( std::index_sequence< I... > ) {
1294 ( step< I , T >( e , t ) , ... );
1295 }( std::make_index_sequence< N >() );
1298 template<
class E ,
class Inv >
1299 void undo(
const Inv & e ,
const Trail & t )
noexcept {
1300 std::uint64_t leave = 0;
1301 [ & ]< std::size_t... I >( std::index_sequence< I... > ) {
1302 ( back< N - 1 - I , E >( e , t , leave ) , ... );
1303 }( std::make_index_sequence< N >() );
1304 if constexpr( may_leave )
1305 for( std::size_t i = 0 ; i < N ; ++i )
1306 if( ( leave >> i ) & 1u )
1311 [[nodiscard]]
bool prepare(
const E & e )
const {
1312 return( [ & ]< std::size_t... I >( std::index_sequence< I... > ) {
1313 return( ( prepareOne< I >( e ) && ... ) );
1314 }( std::make_index_sequence< N >() ) );
1318 [[nodiscard]]
bool audit(
const S & s )
const {
1319 return( [ & ]< std::size_t... I >( std::index_sequence< I... > ) {
1320 return( ( auditOne< I >( s ) && ... ) );
1321 }( std::make_index_sequence< N >() ) );
1324 template<
class Var >
1325 void deliverGroup( std::span< const Var > C , std::uint64_t kinds ,
1326 const Group & g , std::vector< Var > & tmp ) {
1327 [ & ]< std::size_t... I >( std::index_sequence< I... > ) {
1328 ( groupOne< I >( C , kinds , g , tmp ) , ... );
1329 }( std::make_index_sequence< N >() );
1332 [[nodiscard]] Counts counts( std::size_t i )
const {
1333 return( f_counts.at( i ) );
1337 template< std::
size_t I >
1338 [[nodiscard]] std::uint64_t wantedBy(
void )
const {
1339 std::uint64_t m = kinds_of< Ai< I > , Oi< I > , L >::value;
1340 if constexpr( calls_mask< Ai< I > , Oi< I > > )
1341 m &= Ai< I >::mask( std::get< I >( f_o ) );
1342 if constexpr( may_leave )
1343 if( f_off.off( I ) )
1348 template< std::
size_t I ,
bool T ,
class E >
1349 void step(
const E & e , Trail & t ) {
1350 if constexpr( calls< Ai< I > , Oi< I > , E > ) {
1351 if( ! wants< I , E >() )
1353 f_counts.event( I );
1354 if constexpr( std::is_same_v< E , Rebuilt > )
1355 f_counts.rebuild( I );
1356 if constexpr( calls_keep< Ai< I > , Oi< I > , E > ) {
1357 if( Ai< I >::one( std::get< I >( f_o ) , e ) == Keep::Detach )
1361 Ai< I >::one( std::get< I >( f_o ) , e );
1363 t.st |= std::uint64_t( 1 ) << I;
1367 template< std::
size_t I ,
class E ,
class Inv >
1368 void back(
const Inv & e ,
const Trail & t ,
1369 std::uint64_t & leave )
noexcept {
1370 if constexpr( calls< Ai< I > , Oi< I > , Inv > ) {
1371 if( ( ( t.st >> I ) & 1u ) == 0 )
1374 if constexpr( calls_keep< Ai< I > , Oi< I > , Inv > ) {
1375 if( Ai< I >::one( std::get< I >( f_o ) , e ) == Keep::Detach )
1376 leave |= std::uint64_t( 1 ) << I;
1379 Ai< I >::one( std::get< I >( f_o ) , e );
1386 template< std::
size_t I ,
class E >
1387 [[nodiscard]]
bool prepareOne(
const E & e )
const {
1388 if constexpr( calls_prepare< Ai< I > , Oi< I > , E > ) {
1389 if( ! wants< I , E >() )
1391 return( Ai< I >::prepare( std::get< I >( f_o ) , e ) );
1397 template< std::
size_t I ,
class S >
1398 [[nodiscard]]
bool auditOne(
const S & s )
const {
1399 if constexpr( calls_audit< Ai< I > , Oi< I > , S > )
1400 return( Ai< I >::audit( std::get< I >( f_o ) , s ) );
1405 template< std::
size_t I ,
class Var >
1406 void groupOne( std::span< const Var > C , std::uint64_t kinds ,
1408 std::vector< Var > & tmp ) {
1409 const std::uint64_t m = wantedBy< I >();
1410 if( ( m & kinds ) == 0 )
1412 auto & o = std::get< I >( f_o );
1413 f_counts.group( I );
1414 if constexpr( calls_policy< Ai< I > , Oi< I > > )
1415 if( Ai< I >::early( o , eventsFor( C , m , ( kinds & ~m ) == 0 ) ) ) {
1416 rebuiltOne< I >( g );
1419 if constexpr( calls_group< Ai< I > , Oi< I > > )
1420 Ai< I >::begin( o , g );
1422 if constexpr( calls_span< Ai< I > , Oi< I > , Var > ) {
1423 if( ( kinds & ~m ) == 0 )
1424 Ai< I >::many( o , C );
1427 for(
const auto & e : C )
1428 if( ( m >> e.index() ) & 1u )
1430 Ai< I >::many( o , std::span< const Var >( tmp ) );
1435 while( i < C.size() ) {
1436 const std::size_t k = C[ i ].index();
1437 std::size_t j = i + 1;
1438 while( ( j < C.size() ) && ( C[ j ].index() == k ) )
1440 if( ( m >> k ) & 1u )
1441 visitKind< L >( k , [ & ]<
class E >() {
1442 if constexpr( calls< Ai< I > , Oi< I > , E > )
1444 giveRun< Ai< I > , Oi< I > , E >( o ,
1445 C.subspan( i , j - i ) ) || leave;
1450 if constexpr( calls_group< Ai< I > , Oi< I > > )
1452 if constexpr( may_leave )
1457 template< std::
size_t I >
1459 auto & o = std::get< I >( f_o );
1460 f_counts.rebuild( I );
1461 if constexpr( calls_group< Ai< I > , Oi< I > > )
1462 Ai< I >::begin( o , g );
1463 Ai< I >::rebuilt( o );
1464 if constexpr( calls_group< Ai< I > , Oi< I > > )
1468 template< std::size_t... I >
1469 static constexpr void checkOrder( std::index_sequence< I... > ) {
1470 ( checkDeps< I >() , ... );
1473 template< std::
size_t I >
1474 static constexpr void checkDeps(
void ) {
1475 if constexpr(
requires {
typename Oi< I >::depends_on; } )
1476 static_assert( precede< I >(
typename Oi< I >::depends_on() ) ,
1477 "ADS: a static observer precedes one it depends on" );
1480 template< std::size_t I ,
class... D >
1481 static constexpr bool precede( list< D... > ) {
1482 return( ( before< I , D >() && ... ) );
1485 template< std::
size_t I ,
class D >
1486 static constexpr bool before(
void ) {
1487 return( []< std::size_t... J >( std::index_sequence< J... > ) {
1488 return( ( std::is_same_v< Oi< J > , D > || ... ) );
1489 }( std::make_index_sequence< I >() ) );
1502 static constexpr bool slots =
false;
1504 static constexpr bool listened =
false;
1506 [[nodiscard]]
constexpr bool live(
void )
const {
1509 [[nodiscard]]
constexpr std::uint64_t wanted(
void )
const {
return( 0 ); }
1510 template<
class E ,
bool T >
1511 constexpr void deliver(
const E & , Trail & ) { }
1512 template<
class E ,
class Inv >
1513 constexpr void undo(
const Inv & ,
const Trail & )
noexcept { }
1515 [[nodiscard]]
constexpr bool prepare(
const E & )
const {
1519 [[nodiscard]]
constexpr bool audit(
const S & )
const {
1522 template<
class Var >
1523 constexpr void deliverGroup( std::span< const Var > , std::uint64_t ,
1524 const Group & , std::vector< Var > & ) { }
1530template<
class L ,
class Obs >
1534 static constexpr std::size_t K = L::size;
1535 using Var = variant_t< L >;
1541 std::uint64_t mask = 0;
1543 std::array<
Keep ( * )(
void * ,
const void * ) , K > one{};
1545 std::array< bool ( * )(
const void * ,
const void * ) , K > prep{};
1547 std::array< bool ( * )(
void * , std::span< const Var > ) , K > run{};
1549 void ( *all )(
void * , std::span< const Var > ) =
nullptr;
1551 void ( *begin )(
void * ,
const Group & ) =
nullptr;
1552 void ( *end )(
void * ) =
nullptr;
1554 bool ( *audit )(
const void * ,
const void * ) =
nullptr;
1556 bool ( *early )(
void * , std::size_t ) =
nullptr;
1557 void ( *rebuilt )(
void * ) =
nullptr;
1562 static constexpr bool slots =
true;
1565 static constexpr bool listened = contains_v< E , L >;
1568 [[nodiscard]]
bool live(
void )
const {
1569 return( ( f_mask >> index_v< E , L > )&1u );
1572 [[nodiscard]] std::uint64_t wanted(
void )
const {
return( f_mask ); }
1574 template<
class A ,
class D >
1575 int attach( D & o );
1577 void detach(
int id );
1579 [[nodiscard]]
bool attached(
int id )
const {
1580 return( (
id >= 0 ) && (
id <
int( f_s.size() ) ) &&
1581 ( f_s[ std::size_t(
id ) ].o !=
nullptr ) );
1584 template<
class E ,
bool T >
1585 void deliver(
const E & e , Trail & t );
1587 template<
class E ,
class Inv >
1588 void undo(
const Inv & inv ,
const Trail & t )
noexcept;
1591 [[nodiscard]]
bool prepare(
const E & e )
const;
1594 [[nodiscard]]
bool audit(
const S & s )
const;
1596 void deliverGroup( std::span< const Var > C , std::uint64_t kinds ,
1597 const Group & g , std::vector< Var > & tmp );
1599 [[nodiscard]] Counts counts(
int id )
const {
1600 return( f_s[ std::size_t(
id ) ].counts );
1605 bool f_busy =
false;
1609 template<
class A ,
class D , std::
size_t I >
1610 static void fill( Slot & s );
1613 void remask(
void );
1615 std::vector< Slot > f_s;
1616 std::uint64_t f_mask = 0;
1628 static constexpr bool none =
true;
1629 static constexpr bool dynamic =
false;
1630 using modifications = L;
1632 static constexpr bool listened =
false;
1633 constexpr NoSubject(
void ) =
default;
1635 [[nodiscard]]
constexpr bool live(
void )
const {
1639 constexpr void emit(
const E & ) { }
1640 template<
class E ,
class U >
1641 constexpr void emit(
const E & , U && ) { }
1643 constexpr void prepare(
const E & )
const { }
1645 constexpr void audit(
const S & )
const { }
1646 constexpr void open(
void ) { }
1648 constexpr void close(
const S & ) { }
1649 [[nodiscard]]
constexpr std::size_t buffered(
void )
const {
return( 0 ); }
1650 constexpr void discard( std::size_t ) { }
1651 constexpr void spoil(
void ) { }
1652 constexpr void mute(
bool ) { }
1654 constexpr void unmute(
const S & ) { }
1655 [[nodiscard]]
constexpr int depth(
void )
const {
return( 0 ); }
1656 [[nodiscard]]
constexpr bool muted(
void )
const {
return(
false ); }
1657 [[nodiscard]]
constexpr std::size_t built(
void )
const {
return( 0 ); }
1658 [[nodiscard]]
constexpr std::uint64_t mask(
void )
const {
return( 0 ); }
1660 [[nodiscard]]
constexpr std::uint64_t revision(
void )
const {
1663 [[nodiscard]]
constexpr std::uint64_t version(
void )
const {
return( 0 ); }
1669template<
class L ,
class Obs ,
class St ,
class Dy >
1673 static constexpr std::size_t K = L::size;
1674 static_assert( K <= 64 ,
"ADS: at most 64 kinds of event" );
1677 static constexpr bool none =
false;
1678 static constexpr bool dynamic = Dy::slots;
1679 using modifications = L;
1680 using Event = variant_t< L >;
1684 static constexpr bool listened =
1685 St::template listened< E > || Dy::template listened< E >;
1688 template<
class... A >
1689 explicit Subject( A &... a ) : f_st( a... ) { }
1692 Subject(
const Subject & ) =
delete;
1694 Subject & operator=(
const Subject & ) =
delete;
1698 [[nodiscard]]
bool live(
void )
const {
1699 return( f_st.template live< E >() || f_dy.template live< E >() );
1704 void emit(
const E & e ) {
1705 static_assert( contains_v< E , L > ,
1706 "ADS: an event that the structure does not declare" );
1708 if( ( f_depth | f_quiet ) != 0 ) [[unlikely]] {
1714 ++f_rev[ index_v< E , L > ];
1716 if constexpr( dynamic ) {
1717 f_st.template deliver< E , false >( e , t );
1722 ~Done() { b =
false; }
1723 } done{ f_dy.f_busy };
1724 f_dy.template deliver< E , false >( e , t );
1727 f_st.template deliver< E , false >( e , t );
1734 template<
class E ,
class U >
1735 void emit(
const E & e , U && undo );
1740 void prepare(
const E & e )
const {
1741 if constexpr( listened< E > )
1742 if( ! ( f_st.prepare( e ) && f_dy.prepare( e ) ) )
1743 throw( Refused(
"ADS: a change refused by an observer" ) );
1749 void audit( [[maybe_unused]]
const S & s )
const {
1751 if( ( f_depth | f_quiet ) != 0 )
1753 const bool ok = f_st.audit( s ) && f_dy.audit( s );
1761 void open(
void ) { ++f_depth; }
1766 void close(
const S & s );
1769 [[nodiscard]] std::size_t buffered(
void )
const {
return( f_buf.size() ); }
1772 [[nodiscard]] std::span< const Event > collected(
void )
const {
1773 return( std::span< const Event >( f_buf ) );
1778 void discard( std::size_t m );
1781 void spoil(
void ) {
1784 if constexpr( contains_v< Rebuilt , L > )
1785 f_buf.emplace_back( Rebuilt{} );
1789 [[nodiscard]]
int depth(
void )
const {
return( f_depth ); }
1794 void mute(
bool rebuild );
1799 void unmute(
const S & s );
1802 [[nodiscard]]
bool muted(
void )
const {
return( f_quiet > 0 ); }
1807 [[nodiscard]] std::size_t built(
void )
const {
return( f_built ); }
1810 [[nodiscard]] std::uint64_t mask(
void )
const {
1811 return( f_st.wanted() | f_dy.wanted() );
1817 [[nodiscard]] std::uint64_t revision(
void )
const {
1818 return( f_rev[ index_v< E , L > ] );
1822 [[nodiscard]] std::uint64_t revision( std::size_t k )
const {
1823 return( f_rev[ k ] );
1827 [[nodiscard]] std::uint64_t version(
void )
const {
1828 std::uint64_t v = 0;
1829 for(
const auto r : f_rev )
1836 [[nodiscard]] Counts staticCounts( std::size_t i )
const
1837 requires( ! std::is_same_v< St , NoStatic< L > > )
1839 return( f_st.counts( i ) );
1850 ADS_PRE( ( f_depth == 0 ) && ! f_dy.f_busy );
1851 return( f_dy.template attach< Direct >( o ) );
1855 template<
class A ,
class D >
1856 int attachVia( D & o )
1859 ADS_PRE( ( f_depth == 0 ) && ! f_dy.f_busy );
1860 return( f_dy.template attach< A >( o ) );
1865 void detach(
int id )
1868 ADS_PRE( ( f_depth == 0 ) && ! f_dy.f_busy && f_dy.attached(
id ) );
1873 [[nodiscard]]
bool attached(
int id )
const
1876 return( f_dy.attached(
id ) );
1880 [[nodiscard]] Counts slotCounts(
int id )
const
1883 return( f_dy.counts(
id ) );
1896 void rebuilt(
void );
1902 bool f_rebuild =
false;
1903 std::size_t f_built = 0;
1904 std::vector< Event > f_buf;
1906 std::vector< std::shared_ptr< const void > > f_keep;
1907 std::array< std::uint64_t , K > f_rev{};
1913template<
class L ,
class M >
1916 static_assert( std::is_void_v< L > || std::is_same_v< L , M > ,
1917 "ADS: Dynamic< L > on a structure whose events are not L" );
1929 requires ADS::undoable< S >
1930struct checkpoint_of< S >
1932 using type =
decltype( std::declval< S & >().checkpoint() );
1938decltype( auto ) observed( S & s )
1940 if constexpr(
requires { s.observed(); } )
1941 return( s.observed() );
1943 return( std::as_const( s ) );
1960 template<
class L ,
class Obs =
void >
1961 using bind = mod::detail::NoSubject< L >;
1966template<
class... O >
1970 template<
class L ,
class Obs =
void >
1972 mod::detail::Subject< L , Obs , mod::detail::StaticSet< L , Obs , O... > ,
1973 mod::detail::NoSlots< L > >;
1978template<
class L =
void >
1982 template<
class M ,
class Obs =
void >
1984 mod::detail::Subject< typename mod::detail::events_of< L , M >::type , Obs ,
1985 mod::detail::NoStatic< M > ,
1986 mod::detail::Slots< M , Obs > >;
1990template<
class St ,
class Dy = Dynamic<> >
1994template<
class... O ,
class L >
1998 template<
class M ,
class Obs =
void >
2000 mod::detail::Subject< typename mod::detail::events_of< L , M >::type , Obs ,
2001 mod::detail::StaticSet< M , Obs , O... > ,
2002 mod::detail::Slots< M , Obs > >;
2014 using T =
typename mod::detail::checkpoint_of< S >::type;
2019 : f_s( &s ) , f_ex( std::uncaught_exceptions() ) ,
2020 f_mark( s.subject().buffered() ) {
2022 f_t = s.checkpoint();
2028 : f_s( std::exchange( b.f_s ,
nullptr ) ) , f_ex( b.f_ex ) ,
2029 f_mark( b.f_mark ) , f_t( b.f_t ) { }
2045 if( std::uncaught_exceptions() > f_ex )
2078 S * s = std::exchange( f_s ,
nullptr );
2079 s->subject().close( mod::detail::observed( *s ) );
2091 ADS_PRE( revertible( *f_s ) );
2092 undo( *std::exchange( f_s ,
nullptr ) );
2099 bool revertible(
const S & s )
const {
2100 if constexpr(
requires { s.revertible( f_t ); } )
2101 return( s.revertible( f_t ) );
2106 void abandon(
void )
noexcept {
2107 S * s = std::exchange( f_s ,
nullptr );
2109 typename std::remove_cvref_t<
decltype( s->subject() ) >::modifications;
2110 if constexpr( undoable< S > )
2111 if( revertible( *s ) ) {
2116 s->subject().spoil();
2118 s->subject().close( mod::detail::observed( *s ) );
2124 void undo( S & s )
noexcept {
2125 auto & sub = s.subject();
2133 sub.unmute( mod::detail::observed( s ) );
2137 sub.discard( f_mark );
2161 Quiet( S & s ,
bool rebuild ) : f_s( &s ) { s.subject().mute( rebuild ); }
2174 S * s = std::exchange( f_s ,
nullptr );
2175 s->subject().unmute( mod::detail::observed( *s ) );
2192 typename std::remove_cvref_t<
decltype( s.subject() ) >::modifications;
2194 "ADS: quiet( s ) sends Rebuilt, which the structure does not "
2195 "emit; quiet( s , no_rebuild ) promises that nobody needs to "
2242 f_log.push_back(
Event( e ) );
2251 f_log.push_back(
Event( e ) );
2258 void on(
const E & )
noexcept {
2275 return( f_base + f_log.size() );
2279 [[nodiscard]] std::size_t
size(
void )
const {
return( f_log.size() ); }
2290 void forget(
void )
noexcept {
2291 f_base += f_log.size();
2296 std::vector< Event > f_log;
2297 std::size_t f_base = 0;
2298 std::size_t f_floor = 0;
2299 bool f_replay =
false;
2311template<
class Inc ,
class Scratch ,
class Eq = std::equal_to<> >
2316 static constexpr bool forwarded =
2320 static constexpr bool nothrow_for =
2322 noexcept( std::declval< Inc & >().on( std::declval< const E & >() ) ) ) &&
2324 E > ||
noexcept( std::declval< Scratch & >().
on(
2325 std::declval< const E & >() ) ) );
2337 Shadow( Inc & i , Scratch & s , Eq eq = Eq() )
2338 : f_inc( i ) , f_scr( s ) , f_eq( std::move( eq ) ) { }
2342 requires( forwarded< E > )
2343 void on(
const E & e )
noexcept( nothrow_for< E > ) {
2379 auto a = f( f_inc );
2380 const bool same = agreeOn( a , f( f_scr ) );
2387 template< meetable_query T >
2388 [[nodiscard]]
static constexpr auto query( T )
noexcept {
2395 return( agreeOn( f( f_inc ) , f( f_scr ) ) );
2400 [[nodiscard]]
bool audit(
const S & s )
const {
2403 ok = ok &&
bool( f_inc.audit( s ) );
2405 ok = ok &&
bool( f_scr.audit( s ) );
2415 [[nodiscard]] Scratch &
scratch(
void ) {
return( f_scr ); }
2419 static void begin( O & o ,
const mod::Group & g ) {
2424 template<
class A ,
class B >
2425 bool agreeOn(
const A & a ,
const B & b ) {
2427 const bool same = f_eq( a , b );
2448#include "ADS/impl/Modification.tpp"
The capabilities of the structures, beyond the book: what an algorithm may ask of its argument to cho...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The primitives of the processor that the compilers spell each in their own way, in one form for all: ...
a batch of RAII on the structure [see batch()]
Definition Modification.h:2012
void close(void)
closes the batch: the outermost one sends the events, coalesced; idempotent
Definition Modification.h:2076
Batch & operator=(const Batch &)=delete
not assigned
Batch & operator=(Batch &&)=delete
not assigned
void rollback(void)
brings the structure back to where it was when the batch opened, and drops its events: the observers ...
Definition Modification.h:2087
Batch(Batch &&b) noexcept
the batch of , which no longer has it
Definition Modification.h:2027
Batch(S &s)
opens a batch on
Definition Modification.h:2018
~Batch() noexcept(false)
closes the batch, if still open; if its scope exits by an exception, the structure goes back to the c...
Definition Modification.h:2042
Batch(const Batch &)=delete
not copied
void compensate(bool on)
compensated or not from now on
Definition Modification.h:342
bool compensated(void) const
whether the sum is compensated
Definition Modification.h:345
void sub(const T &x)
subtracts
Definition Modification.h:318
T value(void) const
the sum
Definition Modification.h:328
void add(const T &x)
adds
Definition Modification.h:304
void reset(const T &x=T())
the sum set to , with no compensation
Definition Modification.h:336
NeumaierSum(bool compensated=false)
the sum , compensated if compensated
Definition Modification.h:301
a mute of RAII on the structure [see quiet()]
Definition Modification.h:2158
Quiet & operator=(const Quiet &)=delete
not assigned
~Quiet() noexcept(false)
ends the mute, if not yet ended
Definition Modification.h:2169
void end(void)
ends the mute: Rebuilt, or the audit; idempotent
Definition Modification.h:2172
Quiet(S &s, bool rebuild)
suspends the events of
Definition Modification.h:2161
Quiet(const Quiet &)=delete
not copied
a change refused by the prepare() of an observer, before anything changed
Definition Modification.h:161
auto query(F &&f)
the answer of the incremental observer to , compared with that of the other one (a violation at the l...
Definition Modification.h:2378
bool audit(const S &s) const
the audits of both, where they have them
Definition Modification.h:2400
const Counts & counts(void) const
the counts
Definition Modification.h:2410
Scratch & scratch(void)
the observer from scratch
Definition Modification.h:2415
void group_end(void)
the end of a group for both
Definition Modification.h:2358
bool agree(F &&f)
whether the two observers give the same answer to
Definition Modification.h:2394
void group_begin(const mod::Group &g)
the group hooks of both, where they have them
Definition Modification.h:2352
Shadow(Inc &i, Scratch &s, Eq eq=Eq())
the shadow of by , compared by
Definition Modification.h:2337
void on(const E &e) noexcept(nothrow_for< E >)
forwards to both, to those that want it
Definition Modification.h:2343
Inc & incremental(void)
the incremental observer
Definition Modification.h:2413
void flush(void)
flush() of both, where they have it
Definition Modification.h:2366
static constexpr auto query(T) noexcept
the answer of the composition of the two observers to the forwarded query of the tag T [see Capabilit...
Definition Modification.h:2388
an observer that records the invertible events of L, which carry the old values, and brings a structu...
Definition Modification.h:2230
std::size_t size(void) const
the events recorded since the oldest checkpoint still valid
Definition Modification.h:2279
void on(const E &) noexcept
forgets the events recorded, which can no longer be undone: an event with no inverse (the deletion of...
Definition Modification.h:2258
void on(const mod::Cleared &) noexcept
forgets the events recorded, which can no longer be undone
Definition Modification.h:2264
void on(const mod::Replaced< A > &) noexcept
forgets the events recorded
Definition Modification.h:2269
void rollback(S &s, std::size_t t)
back to the checkpoint , by s.apply() of the inverses, in one batch, so that the other observers get ...
void on(const E &e) noexcept(mod::must_not_throw< E >)
< an event recorded
Definition Modification.h:2237
mod::variant_t< L > Event
Definition Modification.h:2232
void on(const mod::Rebuilt &) noexcept
forgets the events recorded
Definition Modification.h:2266
std::size_t checkpoint(void) const
the checkpoint of now
Definition Modification.h:2274
a monoid with the inverse G::inverse( a ), i.e., combine( inverse( a) , a ) and combine( a ,...
Definition Algebra.h:130
a recompute policy: whether to compute from scratch before a repair, whether to abandon a repair whil...
Definition Modification.h:223
a tag of a forwarded query
Definition Capabilities.h:249
an observer that can check itself against the structure
Definition Modification.h:825
an observer that reports counts of its own
Definition Modification.h:837
an observer told of the start and of the end of each batch
Definition Modification.h:806
an event that has an inverse
Definition Modification.h:765
an observer that queues the events and works at its next query
Definition Modification.h:832
an observer with a filter of the kinds at run time: the bit of mask() for the -th event of the struc...
Definition Modification.h:854
an observer of at least one of the events of the list L
Definition Modification.h:877
an observer of the spans of E, an event or the variant of the events
Definition Modification.h:800
an observer of the event E
Definition Modification.h:795
an observer that may refuse the change E before it is made
Definition Modification.h:818
an observer with a recompute policy [see ReoptPolicy], and the statistics of a query after more even...
Definition Modification.h:845
checkpoint() and rollback( t ) back to a checkpoint (a speculative change, a batch that exits by an e...
Definition Capabilities.h:688
constexpr auto query_meet_v
the answer of the composition of A and B to the query T
Definition Capabilities.h:347
@ none
Definition Capabilities.h:553
#define ADS_PRE(cond)
[check]
Definition Contract.h:121
#define ADS_AUDIT(cond)
a precondition or a postcondition dearer than the operation, checked from level 3
Definition Contract.h:131
#define ADS_CONTRACTS
the level of the contracts checked: 0 none, 1 preconditions, 2 postconditions, 3 invariants and audit...
Definition Contract.h:71
constexpr Erased< H, K, V > inverse(const Inserted< H, K, V > &e)
the erasure that undoes an insertion
Definition Modification.h:722
Batch< S > batch(S &s)
a batch on the structure , open while it lives: its events are collected, and the outermost batch sen...
Definition Modification.h:2150
Quiet< S > quiet(S &s)
a mute on the structure : no event while it lives, Rebuilt to every observer at its end (inside a bat...
Definition Modification.h:2189
Changed< Key, H, K > KeyChanged
the key of an item changed
Definition Modification.h:627
constexpr no_rebuild_t no_rebuild
the promise of quiet( s , no_rebuild )
Definition Modification.h:173
constexpr unsigned effects_of
the effects of the event E, all of them if it declares none
Definition Modification.h:418
Changed< Value, H, V > Assigned
the value of an item changed
Definition Modification.h:623
Role
the role of an event in the coalescing of a batch
Definition Modification.h:372
constexpr bool contains_v
whether E is in the list L
Definition Modification.h:523
constexpr Role role_of
the role of the event E, Role::Other if it declares none
Definition Modification.h:414
typename detail::variant_of< L >::type variant_t
the variant of the events of the list L, the type of a buffer
Definition Modification.h:527
Keep
what an on() that returns it asks: to stay, or to be detached after the event, with no exception
Definition Modification.h:156
constexpr std::size_t index_v
the position of E in the list L, its size if absent
Definition Modification.h:519
constexpr bool must_not_throw
whether on() of the event E must not throw: the erasures, the clearing, the rebuilding and the replac...
Definition Modification.h:424
@ Replace
Definition Modification.h:381
@ BulkInsert
Definition Modification.h:378
@ Rebuild
Definition Modification.h:383
@ Other
Definition Modification.h:384
@ Shift
Definition Modification.h:380
@ BulkErase
Definition Modification.h:379
@ Insert
Definition Modification.h:373
@ Relocate
Definition Modification.h:376
@ Clear
Definition Modification.h:382
@ Erase
Definition Modification.h:374
@ Change
Definition Modification.h:375
@ Permute
Definition Modification.h:377
@ Yes
Definition Modification.h:156
@ Detach
Definition Modification.h:156
#define ADS_COLD_PATH
a function of a rare path: never inlined, laid out away from the hot code
Definition Portable.h:107
#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
bool check(const Grid &S, std::size_t x, std::size_t y, int c)
whether can be written in the square of , i.e., it is not on its row, its column or its block
GrB_Type type(void)
the type of GraphBLAS of the numbers T: GrB_BOOL, the integers of 8 to 64 bits with or without sign,...
Definition GraphBLAS.h:128
how two changes of one attribute of one item compose in a batch: the last value (last),...
Definition Modification.h:452
mod::detail::Subject< typename mod::detail::events_of< L, M >::type, Obs, mod::detail::StaticSet< M, Obs, O... >, mod::detail::Slots< M, Obs > > bind
the subject of a structure of the events M
Definition Modification.h:1999
the static observers of St, then those attached at run time
Definition Modification.h:1991
observers attached at run time, the events those of the structure (or the list L, which must be them)
Definition Modification.h:1980
mod::detail::Subject< typename mod::detail::events_of< L, M >::type, Obs, mod::detail::NoStatic< M >, mod::detail::Slots< M, Obs > > bind
the subject of a structure of the events M
Definition Modification.h:1983
nobody listens: the subject is empty and every test is false at compile time, so that the structure c...
Definition Modification.h:1958
mod::detail::NoSubject< L > bind
the subject of a structure of the events L
Definition Modification.h:1961
the default recompute policy: from scratch when the net events exceed times the size,...
Definition Modification.h:239
bool scratch(const ReoptStats &s) const
whether to compute from scratch: , with and the events and the size of , and at the close of a batc...
Definition Modification.h:252
double alpha
the ratio of the work to a scratch
Definition Modification.h:241
bool refresh(std::size_t c, std::size_t n) const
whether the values that are not exact are to be summed again after changes of an instance of size :
Definition Modification.h:273
bool early
whether scratch() acts at the close of
Definition Modification.h:243
bool compensated
whether the sums are compensated
Definition Modification.h:247
void record(int, double) const
nothing: this policy keeps no history
Definition Modification.h:268
double rho
the ratio of the events to the size
Definition Modification.h:240
double period
the changes between two sums, in units
Definition Modification.h:245
bool abandon(const ReoptStats &s, double w) const
whether to abandon the repair after the work : times the work of a scratch, or more than reinsertio...
Definition Modification.h:262
int beta
the reinsertions of one element, 0 off
Definition Modification.h:242
what a recompute policy reads: the work is a count of elementary operations of the observer (nodes,...
Definition Modification.h:208
double work
the work of the repair so far
Definition Modification.h:211
std::size_t reinsertions
the extractions of one element beyond
Definition Modification.h:213
double lastScratch
the work of a computation from scratch
Definition Modification.h:212
bool closing
whether asked at the close of a batch,
Definition Modification.h:215
std::size_t events
the net events to apply
Definition Modification.h:209
std::size_t size
the size of the instance
Definition Modification.h:210
how a query of an observer brought its solution up to date (the outcomes, to ), and why (the causes,...
Definition Modification.h:183
static constexpr int SCRATCH_BY_SIZE
from scratch, too many
Definition Modification.h:187
static constexpr int PARTIAL
a repair stopped by a
Definition Modification.h:194
static constexpr int SCRATCH_BY_ABORT
from scratch, a repair
Definition Modification.h:189
static constexpr int outcomeOf(int c)
the outcome of the cause
Definition Modification.h:199
static constexpr int SCRATCH_BY_EVENT
from scratch, Rebuilt,
Definition Modification.h:191
static constexpr int WARM
by a repair
Definition Modification.h:185
static constexpr int SCRATCH
from scratch
Definition Modification.h:184
static constexpr int CAUSES
the number of the causes
Definition Modification.h:196
static constexpr int CERTIFIED
by the certificate
Definition Modification.h:186
what a shadow counts
Definition Modification.h:2330
std::uint64_t events
the events forwarded
Definition Modification.h:2331
std::uint64_t mismatches
the queries whose answers differ
Definition Modification.h:2333
std::uint64_t queries
the queries compared
Definition Modification.h:2332
the static observers O... (or mod::Via< O , A >), references called directly in the order of the argu...
Definition Modification.h:1968
mod::detail::Subject< L, Obs, mod::detail::StaticSet< L, Obs, O... >, mod::detail::NoSlots< L > > bind
the subject of a structure of the events L
Definition Modification.h:1971
the items of the handles hs erased by one bulk operation
Definition Modification.h:664
static constexpr unsigned effects
it shrinks
Definition Modification.h:665
static constexpr Role role
a bulk erasure
Definition Modification.h:666
std::span< const H > hs
the handles
Definition Modification.h:667
the items of the handles hs inserted by one bulk operation
Definition Modification.h:655
std::span< const H > hs
the handles
Definition Modification.h:658
static constexpr unsigned effects
it grows
Definition Modification.h:656
static constexpr Role role
a bulk insertion
Definition Modification.h:657
the attribute A of the item of handle changed from from to to
Definition Modification.h:600
C value_type
Definition Modification.h:605
C from
Definition Modification.h:607
static constexpr Role role
Definition Modification.h:602
constexpr unsigned direction(void) const
effect::up or effect::down by the order of from and to, 0 if they are equivalent, both if V has no or...
Definition Modification.h:611
bool operator==(const Changed &) const =default
whether the two events are the same
static constexpr unsigned effects
Definition Modification.h:601
C to
Definition Modification.h:608
mod::Value attribute
Definition Modification.h:603
int handle_type
Definition Modification.h:604
int h
Definition Modification.h:606
the structure emptied
Definition Modification.h:699
bool operator==(const Cleared &) const =default
whether the two events are the same
static constexpr unsigned effects
anything
Definition Modification.h:700
static constexpr Role role
a clearing
Definition Modification.h:701
the cost of an arc
Definition Modification.h:438
the counts of an observer kept by the subject at the level of the audits
Definition Modification.h:783
std::uint64_t rebuilds
the Rebuilt received
Definition Modification.h:786
std::uint64_t events
the events received
Definition Modification.h:784
how a subject calls an observer: Direct calls on() and the optional parts by their names; an adapter ...
Definition Modification.h:887
static bool audit(const O &o, const S &s)
o.audit( s )
Definition Modification.h:925
static bool early(O &o, std::size_t k)
whether the policy of wants Rebuilt instead of the events of a batch [see with_policy]
Definition Modification.h:938
static decltype(auto) one(O &o, const E &e) noexcept(noexcept(o.on(e)))
o.on( e )
Definition Modification.h:891
static bool prepare(const O &o, const E &e)
o.prepare( e )
Definition Modification.h:919
static void many(O &o, std::span< const E > s)
o.on( s )
Definition Modification.h:898
static void rebuilt(O &o) noexcept
o.on( Rebuilt{} )
Definition Modification.h:946
static void begin(O &o, const Group &g)
o.group_begin( g ), or o.group_begin()
Definition Modification.h:904
static void end(O &o)
o.group_end()
Definition Modification.h:913
static std::uint64_t mask(const O &o)
o.mask()
Definition Modification.h:931
static constexpr Role role
an erasure
Definition Modification.h:586
K key
the key
Definition Modification.h:591
H handle_type
Definition Modification.h:587
bool operator==(const Erased &) const =default
whether the two events are the same
H h
< no value
Definition Modification.h:590
void value_type
< the key
Definition Modification.h:589
K key_type
< the handle
Definition Modification.h:588
static constexpr unsigned effects
it shrinks
Definition Modification.h:585
the item of handle , key and value erased, told before the removal outside a batch
Definition Modification.h:568
K handle_type
Definition Modification.h:571
static constexpr Role role
Definition Modification.h:570
V value
Definition Modification.h:576
bool operator==(const Erased &) const =default
whether the two events are the same
K key
Definition Modification.h:575
K h
Definition Modification.h:574
V value_type
Definition Modification.h:573
K key_type
Definition Modification.h:572
static constexpr unsigned effects
Definition Modification.h:569
what a batch tells group_begin(): the versions of the subject before and after it,...
Definition Modification.h:775
std::size_t size
its events
Definition Modification.h:778
std::uint64_t from
the version before the batch
Definition Modification.h:776
std::uint64_t to
the version after it
Definition Modification.h:777
void value_type
< the key
Definition Modification.h:557
H handle_type
Definition Modification.h:555
static constexpr Role role
an insertion
Definition Modification.h:554
static constexpr unsigned effects
it grows
Definition Modification.h:553
bool operator==(const Inserted &) const =default
whether the two events are the same
H h
< no value
Definition Modification.h:558
K key_type
< the handle
Definition Modification.h:556
K key
the key
Definition Modification.h:559
the item of handle , key and value inserted
Definition Modification.h:536
static constexpr unsigned effects
Definition Modification.h:537
K key
Definition Modification.h:543
V value
Definition Modification.h:544
V value_type
Definition Modification.h:541
static constexpr Role role
Definition Modification.h:538
K handle_type
Definition Modification.h:539
K h
Definition Modification.h:542
bool operator==(const Inserted &) const =default
whether the two events are the same
K key_type
Definition Modification.h:540
the attribute of a key that orders the items
Definition Modification.h:436
the lower bound of an arc
Definition Modification.h:442
the parent of a node in a forest, -1 at a root
Definition Modification.h:446
the items permuted: the handle before of each handle after
Definition Modification.h:646
std::span< const H > old_of_new
the old handle of each
Definition Modification.h:649
static constexpr unsigned effects
no value changes
Definition Modification.h:647
static constexpr Role role
a permutation
Definition Modification.h:648
anything may have changed: forget and recompute
Definition Modification.h:708
static constexpr Role role
a rebuilding
Definition Modification.h:710
static constexpr unsigned effects
anything
Definition Modification.h:709
bool operator==(const Rebuilt &) const =default
whether the two events are the same
the item of handle from moved to the handle to, for the structures whose handles are not stable
Definition Modification.h:633
bool operator==(const Relocated &) const =default
whether the two events are the same
std::size_t to
Definition Modification.h:638
std::size_t from
Definition Modification.h:637
static constexpr unsigned effects
Definition Modification.h:634
H handle_type
Definition Modification.h:636
static constexpr Role role
Definition Modification.h:635
every value of the attribute A replaced
Definition Modification.h:689
static constexpr unsigned effects
anything
Definition Modification.h:690
static constexpr Role role
a replacement
Definition Modification.h:691
bool operator==(const Replaced &) const =default
< the attribute
A attribute
Definition Modification.h:692
every value of the attribute A moved by delta
Definition Modification.h:673
D delta
< the attribute
Definition Modification.h:677
static constexpr Role role
a shift of all
Definition Modification.h:675
constexpr unsigned direction(void) const
effect::up or effect::down by the sign of delta
Definition Modification.h:679
bool operator==(const Shifted &) const =default
whether the two events are the same
static constexpr unsigned effects
both
Definition Modification.h:674
A attribute
Definition Modification.h:676
the supply of a node
Definition Modification.h:444
the upper bound of an arc
Definition Modification.h:440
the attribute of the value of an item
Definition Modification.h:434
the observer O called through the adapter A, an argument of Static
Definition Modification.h:954
the net effect of the events of a batch of the structures whose events are the list L: by default the...
Definition Modification.h:968
static std::vector< variant_t< L > > coalesce(std::span< const variant_t< L > > B)
the net effect of the events , in expected time
the effects of an event, as bits: a bit not set is a guarantee
Definition Modification.h:363
static constexpr unsigned grows
the structure may grow
Definition Modification.h:364
static constexpr unsigned down
a value may decrease
Definition Modification.h:367
static constexpr unsigned all
all of them
Definition Modification.h:368
static constexpr unsigned shrinks
it may shrink
Definition Modification.h:365
static constexpr unsigned up
a value may increase
Definition Modification.h:366
a list of types, the events of a structure [see Modification.h]
Definition Modification.h:482
static constexpr std::size_t size
Definition Modification.h:483
the value after the second change
Definition Modification.h:454
the largest of the two values after
Definition Modification.h:458
the least of the two values after
Definition Modification.h:456
the first value after plus the second difference
Definition Modification.h:460
typename A::reduction type
Definition Modification.h:476
the reduction of the attribute A: A::reduction if it has one, reduce::last otherwise
Definition Modification.h:467
reduce::last type
Definition Modification.h:468
the promise of quiet( s , no_rebuild ): nobody needs to know
Definition Modification.h:168
constexpr no_rebuild_t(void)=default