ReFRACtor
|
Caches ArrayAd objects using a std::vector. More...
#include <array_ad_cache.h>
Public Member Functions | |
ArrayAdVectorCache (int prealloc_size=0) | |
Optionally pass a preallocation size. More... | |
virtual std::vector< std::pair< K, ArrayAd< T, D > > > | cached_data () const |
Obtain cached data up to last point inserted. More... | |
virtual void | clear () |
clear simply resets the location of of the cache index by default without clearing any memory. More... | |
virtual void | clear (bool clear_memory) |
Clear the vector as well as reset insertion location. More... | |
virtual void | erase (const K &key) |
Removes a specific item from the vector This call can be expensive since it will need to shift items down. More... | |
std::vector< std::pair< K, ArrayAd< T, D > > >::const_iterator | find (const K &key) const |
Finds the requested item using a STL lower bound call. More... | |
std::vector< std::pair< K, ArrayAd< T, D > > >::iterator | find (const K &key) |
Finds the requested item using a STL lower bound call. More... | |
virtual void | insert (const K &key, const ArrayAd< T, D > &value) |
Insert the cached item into the currently available slot in the vector or creates a new slot. More... | |
virtual bool | is_valid (const K &key) const |
virtual ArrayAd< T, D > | operator[] (const K &key) const |
Retrieve a specific key and error if it is no keys are available However, will return the closest one available. More... | |
Caches ArrayAd objects using a std::vector.
This class should be used when the cached data is calculated in order and will be used again in order. Using operator[] is slower than the same one from a map cache.
The cached data is available through a method so it can be looped over. Which is what you want anyways.
Additional speed can be obtained if the size of the data to cache is known beforehand and that size is passed during construction. The class will not release memory unless it is specifically instructed and will reuse the vector on subsequent clears and insertion cycles.
Definition at line 86 of file array_ad_cache.h.
|
inline |
Optionally pass a preallocation size.
Definition at line 91 of file array_ad_cache.h.
|
inlinevirtual |
Obtain cached data up to last point inserted.
Definition at line 177 of file array_ad_cache.h.
|
inlinevirtual |
clear simply resets the location of of the cache index by default without clearing any memory.
Implements FullPhysics::ArrayAdCache< K, T, D >.
Definition at line 163 of file array_ad_cache.h.
|
inlinevirtual |
Clear the vector as well as reset insertion location.
Definition at line 169 of file array_ad_cache.h.
|
inlinevirtual |
Removes a specific item from the vector This call can be expensive since it will need to shift items down.
Implements FullPhysics::ArrayAdCache< K, T, D >.
Definition at line 151 of file array_ad_cache.h.
|
inline |
Finds the requested item using a STL lower bound call.
Definition at line 97 of file array_ad_cache.h.
|
inline |
Finds the requested item using a STL lower bound call.
Definition at line 109 of file array_ad_cache.h.
|
inlinevirtual |
Insert the cached item into the currently available slot in the vector or creates a new slot.
Implements FullPhysics::ArrayAdCache< K, T, D >.
Definition at line 138 of file array_ad_cache.h.
|
inlinevirtual |
Implements FullPhysics::ArrayAdCache< K, T, D >.
Definition at line 131 of file array_ad_cache.h.
|
inlinevirtual |
Retrieve a specific key and error if it is no keys are available However, will return the closest one available.
Implements FullPhysics::ArrayAdCache< K, T, D >.
Definition at line 122 of file array_ad_cache.h.