MRU< T > Class Template Reference
A template container designed to provide a lightweight "most recently used" functionality. "Least recently used" is also implemented.
More...
#include <mru.h>
List of all members.
Detailed Description
template<class T>
class cxxtls::MRU< T >
A template container designed to provide a lightweight "most recently used" functionality. "Least recently used" is also implemented.
Key features:
- use activate(T) to both add items and promote them to be the most recently used.
- use discard(T) to remove items from the container
- use mostRecent() to get an iterator to the most recently activated item. May return end..
- use leastRecent() to get an iterator to the least recently activated item. May return end().
The general expectation is that applications will use this container to access no more than a few hundred items. A hash_list could be used for the rep_type if more than this will be needed. It provides O(1) amortized lookups which will speed up finds.
Definition at line 37 of file mru.h.
Member Typedef Documentation
Definition at line 67 of file mru.h.
Definition at line 65 of file mru.h.
Definition at line 64 of file mru.h.
Member Function Documentation
void activate |
( |
T const & |
item |
) |
|
Find the item of interest and mark it as the most recently used or add it to the container as the most recently used.
Definition at line 87 of file mru.h.
void discard |
( |
T const & |
item |
) |
|
Remove the specified item from the container.
Definition at line 102 of file mru.h.
- Returns:
- true if container is empty
Definition at line 85 of file mru.h.
- Returns:
- the end of the container
Definition at line 69 of file mru.h.
iterator find |
( |
T const & |
query |
) |
[private] |
- Returns:
- the least recently used item or end()
Definition at line 73 of file mru.h.
- Returns:
- most recently used or end()
Definition at line 71 of file mru.h.
Member Data Documentation
The documentation for this class was generated from the following file: