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>

Inheritance diagram for MRU< T >:
Inheritance graph
[legend]

List of all members.

Public Types

typedef rep_type::iterator iterator
typedef std::list< T > rep_type
typedef T value_type

Public Member Functions

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.
void discard (T const &item)
 Remove the specified item from the container.
bool empty () const
iterator end ()
iterator leastRecent ()
iterator mostRecent ()

Private Member Functions

iterator find (T const &query)

Private Attributes

rep_type data_

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:

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.

typedef std::list<T> rep_type

Definition at line 65 of file mru.h.

typedef T value_type

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.

Here is the caller graph for this function:

void discard ( T const &  item  ) 

Remove the specified item from the container.

Definition at line 102 of file mru.h.

Here is the caller graph for this function:

bool empty (  )  const
Returns:
true if container is empty

Definition at line 85 of file mru.h.

Here is the caller graph for this function:

iterator end (  ) 
Returns:
the end of the container

Definition at line 69 of file mru.h.

Here is the caller graph for this function:

iterator find ( T const &  query  )  [private]

Definition at line 116 of file mru.h.

Here is the caller graph for this function:

iterator leastRecent (  ) 
Returns:
the least recently used item or end()

Definition at line 73 of file mru.h.

iterator mostRecent (  ) 
Returns:
most recently used or end()

Definition at line 71 of file mru.h.

Here is the caller graph for this function:


Member Data Documentation

rep_type data_ [private]

Definition at line 114 of file mru.h.


The documentation for this class was generated from the following file:
Generated on Wed Feb 29 22:56:09 2012 for CXXUtilities by  doxygen 1.6.3