PcapPlusPlus
19.12
|
#include <LRUList.h>
Public Member Functions | |
LRUList (size_t maxSize) | |
int | put (const T &element, T *deletedValue=NULL) |
const T & | getMRUElement () const |
const T & | getLRUElement () const |
void | eraseElement (const T &element) |
size_t | getMaxSize () const |
size_t | getSize () const |
A template class that implements a LRU cache with limited size. Each time the user puts an element it goes to head of the list as the most recently used element (if the element was already in the list it advances to the head of the list). The last element in the list is the one least recently used and will be pulled out of the list if it reaches its max size and a new element comes in. All actions on this LRU list are O(1)
|
inline |
A c'tor for this class
[in] | maxSize | The max size this list can go |
|
inline |
Erase an element from the list. If element isn't found in the list nothing happens
[in] | element | The element to erase |
|
inline |
Get the least recently used element (the one at the end of the list)
|
inline |
|
inline |
Get the most recently used element (the one at the beginning of the list)
|
inline |
|
inline |
Puts an element in the list. This element will be inserted (or advanced if it already exists) to the head of the list as the most recently used element. If the list already reached its max size and the element is new this method will remove the least recently used element and return a value in deletedValue. Method complexity is O(log(getSize())). This is a optimized version of the method T* put(const T&).
[in] | element | The element to insert or to advance to the head of the list (if already exists) |
[out] | deletedValue | The value of deleted element if a pointer is not NULL. This parameter is optional. |