|
| CircularBuffer (int iSize) |
|
| CircularBuffer (CircularBuffer const &iOther) |
|
void | copyToBuffer (int startOffset, T *oBuffer, int iSize) |
|
template<typename U , class BinaryPredicate > |
U | fold (int startOffset, int endOffsetNotIncluded, U initValue, BinaryPredicate &op) const |
| "standard" implementation of the fold algorithm starting at startOffset and ending at endOffsetNotIncluded (which as the name hinted is NOT included). More...
|
|
template<typename U , class BinaryPredicate > |
U | fold (int endOffsetNotIncluded, U initValue, BinaryPredicate &op) const |
| Shortcut with startOffset 0. More...
|
|
template<typename U , class BinaryPredicate > |
U | fold (U initValue, BinaryPredicate &op) const |
| Shortcut for entire buffer (starting at startOffset 0) More...
|
|
template<typename U , class BinaryPredicateWithIndex > |
U | foldWithIndex (int startOffset, int endOffsetNotIncluded, U initValue, BinaryPredicateWithIndex &op) const |
| Similar to fold but BinaryPredicateWithIndex is also provided the index (starting at startOffset ) More...
|
|
template<typename U , class BinaryPredicateWithIndex > |
U | foldWithIndex (int endOffsetNotIncluded, U initValue, BinaryPredicateWithIndex &op) const |
| Shortcut with startOffset = 0. More...
|
|
template<typename U , class BinaryPredicateWithIndex > |
U | foldWithIndex (U initValue, BinaryPredicateWithIndex &op) const |
| Shortcut for entire buffer (starting at startOffset 0) More...
|
|
T | getAt (int offset) const |
|
int | getSize () const |
|
void | incrementHead () |
|
void | init (T initValue) |
|
void | push (T e) |
|
void | setAt (int offset, T e) |
|
| ~CircularBuffer () |
|
U fold |
( |
int |
startOffset, |
|
|
int |
endOffsetNotIncluded, |
|
|
U |
initValue, |
|
|
BinaryPredicate & |
op |
|
) |
| const |
|
inline |
"standard" implementation of the fold algorithm starting at startOffset
and ending at endOffsetNotIncluded
(which as the name hinted is NOT included).
This implementation works fine whether startOffset
is less or more than endOffsetNotIncluded
(in which case the direction of iteration is reversed). It also handles properly wrapping around the buffer (potentially multiple times...).
The fold algorithm is the following:
resultValue = initValue;
resultValue = op(resultValue, fBuf[<adjusted start offset>]);
resultValue = op(resultValue, fBuf[<adjusted start offset> + 1]);
...
return resultValue;
Technically speaking the BinaryPredicate
is defined like this
template<typename U>
using BinaryPredicate = U (*)(U const&, T const&);
BUT it is not really defined in the following methods because of the fact that lambda with capture cannot be converted to it... where by defining it loosely this way, it just works...