PcapPlusPlus
|
#include <LRUList.h>
Public Member Functions | |
LRUList (size_t maxSize) | |
T * | put (const T &element) |
const T & | getMRUElement () |
const T & | getLRUElement () |
void | eraseElement (const T &element) |
size_t | getMaxSize () |
size_t | getSize () |
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 pointer to it. Method complexity is O(1)
[in] | element | The element to insert or to advance to the head of the list (if already exists) |