|
ADS
Algorithms and Data Structures
|
An array that tells its changes, beyond the book: a vector of values of T whose writes go through the subject policy Policy [see Modification.h], NoObservers by default, with which every operation compiles to the code of the std::vector it holds. More...
#include "ADS/Contract.h"#include "ADS/Modification.h"#include "ADS/Portable.h"#include <cstddef>#include <initializer_list>#include <iterator>#include <utility>#include <vector>#include "ADS/sequence/impl/ObservableArray.tpp"Go to the source code of this file.
Classes | |
| class | ADS::ObservableArray< T, Policy > |
| an array of values of T whose changes are told through Policy More... | |
Namespaces | |
| namespace | ADS |
An array that tells its changes, beyond the book: a vector of values of T whose writes go through the subject policy Policy [see Modification.h], NoObservers by default, with which every operation compiles to the code of the std::vector it holds.
The handle of a value is its index, which is also the key of its insertion and erasure: set( i , v ) and add( i , d ) send Assigned with the value before and the value after (after the write), push_back() sends Inserted (after it), pop_back() sends Erased with the last value (before it), clear() sends Cleared and assign() sends Rebuilt (after them). The reads, operator[], data() and the iterators, are those of the vector and never change it; a change of a value may only go through the array.
Since the events carry the old and the new values, an observer keeps a view of the array (its prefix sums [see Fenwick.h], a segment tree, an index) without reading it, and a batch [see batch()] sends the net effect of its writes per index, the changes of one index composed into one by (1.15) of Typed modifications. apply( e ) makes the change of an event, so that an UndoLog of the array brings it back to a checkpoint.
The contracts [see Contract.h]: the indices of set(), add() and operator[] are in \( [ 0 , n ) \), pop_back() needs an array that is not empty, apply() an event that starts from the present state. The operations are defined in ObservableArray.tpp.