|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Cell state carrying a fixed-depth ring buffer of past values. More...
#include <tpl_ca_continuous_rules.H>
Public Types | |
| using | value_type = State |
| Base value type stored in the ring buffer. | |
Public Member Functions | |
| History_Cell ()=default | |
| Construct a zero/default history. | |
| History_Cell (const State &value) | |
Construct a history with every slot initialized to value. | |
| History_Cell (const std::array< State, Depth > &values, const std::size_t head=0) | |
| Construct a history from raw ring contents. | |
| State | current () const |
| Return the current value. | |
| State | previous (const std::size_t age) const |
| Return a previous value by age. | |
| void | push (const State &value) |
| Push a new current value into the ring. | |
| std::size_t | head () const noexcept |
| Return the current ring head index. | |
| const std::array< State, Depth > & | values () const noexcept |
| Return the raw ring storage. | |
| bool | operator== (const History_Cell &rhs) const |
| Compare two history cells exactly. | |
Static Public Attributes | |
| static constexpr std::size_t | depth_v = Depth |
| Number of retained states. | |
Private Attributes | |
| std::array< State, Depth > | values_ {} |
| std::size_t | head_ = 0 |
Cell state carrying a fixed-depth ring buffer of past values.
current() returns the value at the active ring head. previous(1) returns the value that was current before the last push(), and so on up to previous(Depth - 1).
| State | value stored in each history slot. |
| Depth | number of slots retained per cell; must be positive. |
Definition at line 635 of file tpl_ca_continuous_rules.H.
| using Aleph::CA::History_Cell< State, Depth >::value_type = State |
Base value type stored in the ring buffer.
Definition at line 641 of file tpl_ca_continuous_rules.H.
|
default |
Construct a zero/default history.
| This | function does not throw if State construction does not throw. |
|
inlineexplicit |
Construct a history with every slot initialized to value.
| [in] | value | value copied into every slot. |
| Any | exception thrown by State copy assignment. |
Definition at line 662 of file tpl_ca_continuous_rules.H.
References value, and Aleph::CA::History_Cell< State, Depth >::values_.
|
inline |
Construct a history from raw ring contents.
| [in] | values | ring storage. |
| [in] | head | index of the current value. |
| std::out_of_range | if head >= Depth. |
Definition at line 673 of file tpl_ca_continuous_rules.H.
References ah_out_of_range_error_if, Aleph::blossom_maximum_cardinality_matching(), and Aleph::CA::History_Cell< State, Depth >::head_.
|
inline |
Return the current value.
| This | function does not throw if State copy does not throw. |
Definition at line 685 of file tpl_ca_continuous_rules.H.
References Aleph::CA::History_Cell< State, Depth >::head_, and Aleph::CA::History_Cell< State, Depth >::values_.
Referenced by Aleph::CA::History_Rule< Depth, F >::operator()().
|
inlinenoexcept |
Return the current ring head index.
[0, Depth). | This | function does not throw. |
Definition at line 723 of file tpl_ca_continuous_rules.H.
References Aleph::CA::History_Cell< State, Depth >::head_.
|
inline |
Compare two history cells exactly.
| [in] | rhs | cell to compare with. |
| This | function does not throw if State comparison does not throw. |
Definition at line 745 of file tpl_ca_continuous_rules.H.
References Aleph::and, Aleph::CA::History_Cell< State, Depth >::head_, and Aleph::CA::History_Cell< State, Depth >::values_.
|
inline |
Return a previous value by age.
age == 0 is the current value. age == 1 is the value before the most recent push().
| [in] | age | age in [0, Depth). |
| std::out_of_range | if age >= Depth. |
Definition at line 699 of file tpl_ca_continuous_rules.H.
References ah_out_of_range_error_if, Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::History_Cell< State, Depth >::head_, and Aleph::CA::History_Cell< State, Depth >::values_.
Referenced by Aleph::CA::History_Rule< Depth, F >::operator()().
|
inline |
Push a new current value into the ring.
| [in] | value | value that becomes current(). |
| Any | exception thrown by State assignment. |
Definition at line 712 of file tpl_ca_continuous_rules.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::History_Cell< State, Depth >::head_, value, and Aleph::CA::History_Cell< State, Depth >::values_.
Referenced by Aleph::CA::History_Rule< Depth, F >::operator()().
|
inlinenoexcept |
Return the raw ring storage.
| This | function does not throw. |
Definition at line 733 of file tpl_ca_continuous_rules.H.
References Aleph::CA::History_Cell< State, Depth >::values_.
|
staticconstexpr |
Number of retained states.
Definition at line 643 of file tpl_ca_continuous_rules.H.
|
private |
Definition at line 647 of file tpl_ca_continuous_rules.H.
Referenced by Aleph::CA::History_Cell< State, Depth >::History_Cell(), Aleph::CA::History_Cell< State, Depth >::current(), Aleph::CA::History_Cell< State, Depth >::head(), Aleph::CA::History_Cell< State, Depth >::operator==(), Aleph::CA::History_Cell< State, Depth >::previous(), and Aleph::CA::History_Cell< State, Depth >::push().
|
private |
Definition at line 646 of file tpl_ca_continuous_rules.H.
Referenced by Aleph::CA::History_Cell< State, Depth >::History_Cell(), Aleph::CA::History_Cell< State, Depth >::current(), Aleph::CA::History_Cell< State, Depth >::operator==(), Aleph::CA::History_Cell< State, Depth >::previous(), Aleph::CA::History_Cell< State, Depth >::push(), and Aleph::CA::History_Cell< State, Depth >::values().