A variable size storage utility for objects of type RecordType with absolute maximum MaxItemCount.
More...
|
RecordType * | begin () |
|
RecordType * | end () |
|
void | clear () |
| invalidate all records. More...
|
|
constexpr RecordType * | get (const IdType &id) |
| linear search for the first record which has id() == id. More...
|
|
template<class UnaryPredicate > |
constexpr RecordType * | get (UnaryPredicate p) |
| returns the first object obj in the store satisfying p(obj) == true . More...
|
|
template<class ValueFunction > |
constexpr RecordType * | getMin (ValueFunction getValue) |
| Returns a pointer to the element in the store which minimizes the value function val . More...
|
|
RecordType * | getOrAdd (IdType id) |
| same as get, but will return pointer to an invalid element if such element exists, possibly incrementing _currentSize. More...
|
|
constexpr RecordType * | add () |
| returns a pointer to the first invalid record. More...
|
|
constexpr RecordType * | addAtEnd () |
| increases size of the store if possible and returns the entry at the end(), after invalidating. More...
|
|
uint16_t | size () |
|
template<class UnaryPredicate > |
constexpr uint16_t | countIf (UnaryPredicate p) |
| returns number of elements that satisfy the predicate. More...
|
|
constexpr uint16_t | count () |
| returns number of valid elements. More...
|
|
constexpr bool | full () |
| returns true if all elements are occupied and valid. More...
|
|
template<class RecordType, unsigned int MaxItemCount>
class Store< RecordType, MaxItemCount >
A variable size storage utility for objects of type RecordType with absolute maximum MaxItemCount.
Can be stack allocated.
RecordType should implement:
- IdType id();
- bool isValid();
- void invalidate();
Where IdType is freely dependent on RecordType. Furthermore it must be default constructible.
template<class RecordType , unsigned int MaxItemCount>
template<class UnaryPredicate >
constexpr RecordType * Store< RecordType, MaxItemCount >::get |
( |
UnaryPredicate |
p | ) |
|
|
inlineconstexpr |
returns the first object obj
in the store satisfying p(obj) == true
.
(useful if comparing to other things than obj.id()
NOTE: this does not check for isValid, because you may want to find the first invalid item for example!
template<class RecordType , unsigned int MaxItemCount>
template<class ValueFunction >
constexpr RecordType * Store< RecordType, MaxItemCount >::getMin |
( |
ValueFunction |
getValue | ) |
|
|
inlineconstexpr |
Returns a pointer to the element in the store which minimizes the value function val
.
Only considers records with isValid() == true
.
ValueFunction is a function (or function like object) that takes an object of type RecordType
as argument and returns the value that should be minimized.