Slicer
4.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
|
#include <Libs/vtkITK/itkTimeSeriesDatabaseHelper.h>
Public Member Functions | |
void | clear () |
void | debug_dump (ostream &ostr=cerr) |
bool | empty () |
ValueType * | find (const KeyType &key) |
string | format_str (const char *format,...) const |
NDEBUG. More... | |
unsigned | get_maxsize () |
void | insert (const KeyType &key, const ValueType &value) |
LRUCache (unsigned maxsize_=100) | |
void | set_maxsize (unsigned maxsize_) |
size_t | size () |
void | statistics (ostream &ostr=cerr) const |
~LRUCache () | |
A cache class.
Stores cached values for keys. Yseful when the value is a result of some complex calculation on key that we want to avoid doing repeatedly.
The basic interface is insert() for insertions and find() to look up items. key_type must have operator < defined.
Has a maximal size (amount of elements - key/value pairs) and employs a LRU (Least Recently Used) removal policy when that maximum is exceeded, meaning that the item which was accesses least recently is removed.
The class also keeps statistics, cache hit/miss rate that may be useful while debugging. The statistics counting works only if NDEBUG is not defined.
Definition at line 102 of file itkTimeSeriesDatabaseHelper.h.
|
inline |
Create a new cache.
maxsize_ | maximal size of the cache |
Definition at line 109 of file itkTimeSeriesDatabaseHelper.h.
|
inline |
Definition at line 122 of file itkTimeSeriesDatabaseHelper.h.
|
inline |
Clear the cache.
Definition at line 143 of file itkTimeSeriesDatabaseHelper.h.
|
inline |
Dumps the cache to output.
Useful for debugging. Expects key/value types to have an output operator (<<) defined.
Definition at line 225 of file itkTimeSeriesDatabaseHelper.h.
|
inline |
Is the cache empty ?
Definition at line 136 of file itkTimeSeriesDatabaseHelper.h.
|
inline |
Looks for a key in the cache.
Returns a pointer to the value if found, 0 otherwise.
Warning: a bare pointer is returned, at the user's risk. The pointer may become invalid at some time, so it should be used immediately.
An access moves the element to the front of the list (marking it MRU).
Definition at line 200 of file itkTimeSeriesDatabaseHelper.h.
|
inline |
NDEBUG.
Works like sprintf, but returns the resulting string in a memory-safe manner.
Definition at line 275 of file itkTimeSeriesDatabaseHelper.h.
|
inline |
Definition at line 118 of file itkTimeSeriesDatabaseHelper.h.
|
inline |
Inserts a key/value pair to the cache.
Is the key already in the cache ? Note: find() is used intentionally - if an element gets updated, it should be moved to be MRU.
Found ?
Update the value.
Add it to the table and to the front of the list (mark it MRU).
If the maximal size was exceeded, clean up LRU element.
Definition at line 152 of file itkTimeSeriesDatabaseHelper.h.
|
inline |
Definition at line 114 of file itkTimeSeriesDatabaseHelper.h.
|
inline |
How many elements are currently stored in the cache ?
Definition at line 129 of file itkTimeSeriesDatabaseHelper.h.
|
inline |
Prints cache statistics.
Only in debug mode (NDEBUG not defined).
Definition at line 255 of file itkTimeSeriesDatabaseHelper.h.