Data Structures & Algorithms in C++
Goodrich, Tamassia, Mount and Goldwasser
|
Maintains a list of elements ordered using move-to-front heuristic. More...
#include <favorites_list_mtf.h>
Public Member Functions | |
void | access (T elem) |
Accessess element (possibly new), increasing its access count. | |
std::list< T > | get_favorites (int k) const |
Returns an ordered list of the k most frequently accessed elements. | |
![]() | |
int | size () const |
Returns number of distinct elements in the list. | |
bool | empty () const |
Returns true if the list is non-empty. | |
void | access (T elem) |
Accessess element (possibly new), increasing its access count. | |
void | remove (T elem) |
Removes the given element from the list of favorites (if found) | |
std::list< T > | get_favorites (int k) const |
Returns an ordered list of the k most frequently accessed elements. | |
Additional Inherited Members | |
![]() | |
typedef std::list< std::pair< int, T > >::iterator | iterator |
typedef std::list< std::pair< int, T > >::const_iterator | const_iterator |
![]() | |
iterator | find (T elem) |
![]() | |
std::list< std::pair< int, T > > | contents |
Maintains a list of elements ordered using move-to-front heuristic.
|
inline |
Accessess element (possibly new), increasing its access count.
|
inline |
Returns an ordered list of the k most frequently accessed elements.