23 #ifndef __ccxx_AbstractCache_hxx 24 #define __ccxx_AbstractCache_hxx 60 virtual T*
get(
const K& key) = 0;
66 {
return(this->
get(key)); }
94 {
return(_map.size()); }
100 {
return(_map.empty()); }
106 {
return(_map.size() == _maxSize); }
128 virtual void onRemove(
const K& key, T* item);
135 Link(K key, T* data = NULL)
153 typedef Link LinkType;
157 bool operator()(
const Link* key1,
const Link* key2)
const 158 {
return(key1->key < key2->key); }
161 void _link(Link* link)
const;
162 void _unlink(Link* link)
const;
164 typedef std::set<Link*, KeyCompare> MapType;
165 mutable MapType _map;
171 #include <commonc++/AbstractCacheImpl.h++> 175 #endif // __ccxx_AbstractCache_hxx
bool contains(const K &key) const
Test if the cache contains an item with the specified key.
bool isFull() const
Test if the cache is full.
Definition: AbstractCache.h++:105
unsigned int uint_t
An alias for unsigned int.
Definition: Integers.h++:74
bool isEmpty() const
Test if the cache is empty.
Definition: AbstractCache.h++:99
virtual ~AbstractCache()
Destructor.
An abstract base class for a general-purpose LRU-cache with a maximum capacity.
Definition: AbstractCache.h++:46
uint_t getSize() const
Return the current size of the cache, i.e., the number of items in the cache.
Definition: AbstractCache.h++:93
virtual void clear()
Remove all items from the cache.
AbstractCache(uint_t maxSize)
Construct a new cache with the given maximum size.
virtual void onRemove(const K &key, T *item)
A method that is called whenever an item is being removed from the cache, but just before it has been...
Definition: AllocationMap.c++:25
T * operator[](const K &key)
Index operator.
Definition: AbstractCache.h++:65
uint_t getMaxSize() const
Return the maximum size of the cache, i.e., the maximum number of items that the cache can hold...
Definition: AbstractCache.h++:86