18 #ifndef _DECAF_UTIL_LRUCACHE_H_ 19 #define _DECAF_UTIL_LRUCACHE_H_ 42 template<
typename K,
typename V,
typename HASHCODE = HashCode<K> >
63 LinkedHashMap<K, V, HASHCODE>(0, 0.75f, true), maxCacheSize(maximumCacheSize) {
65 if (maximumCacheSize <= 0) {
67 __FILE__, __LINE__,
"Cache size must be greater than zero.");
88 LinkedHashMap<K, V, HASHCODE>(initialCapacity, loadFactor, accessOrder), maxCacheSize(maximumCacheSize) {
90 if (maximumCacheSize <= 0) {
92 __FILE__, __LINE__,
"Cache size must be greater than zero.");
118 __FILE__, __LINE__,
"Cache size must be greater than zero.");
121 this->maxCacheSize =
size;
127 if (this->
size() > maxCacheSize) {
virtual ~LRUCache()
Definition: LRUCache.h:96
LRUCache(int maximumCacheSize)
Constructs a LRUCache with a maximum capacity.
Definition: LRUCache.h:62
int maxCacheSize
Definition: LRUCache.h:46
LRUCache(int initialCapacity, int maximumCacheSize, float loadFactor, bool accessOrder)
Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize, load factor and ordering mode.
Definition: LRUCache.h:87
LRUCache()
Default constructor for an LRU Cache The default capacity is 10000.
Definition: LRUCache.h:54
A Basic Least Recently Used (LRU) Cache Map.
Definition: LRUCache.h:43
int getMaxCacheSize() const
Gets the currently configured Max Cache Size setting.
Definition: LRUCache.h:103
Hashed and linked list implementation of the Map interface, with predictable iteration order...
Definition: LinkedHashMap.h:111
virtual int size() const
Definition: HashMap.h:943
Definition: IllegalArgumentException.h:31
Definition: MapEntry.h:27
virtual bool removeEldestEntry(const MapEntry< K, V > &eldest DECAF_UNUSED)
This method is queried from the put and putAll methods to check if the eldest member of the map shoul...
Definition: LRUCache.h:126
#define DECAF_UNUSED
Definition: Config.h:160
float loadFactor
Definition: HashMap.h:760
void setMaxCacheSize(int size)
Sets the maximum size allowed for this LRU Cache.
Definition: LRUCache.h:115
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25