|
Data Structures & Algorithms in C++
Goodrich, Tamassia, Mount and Goldwasser
|
Maintains a list of elements ordered according to access frequency. More...
#include <favorites_list.h>


Public Member Functions | |
| 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. | |
Protected Types | |
| typedef std::list< std::pair< int, T > >::iterator | iterator |
| typedef std::list< std::pair< int, T > >::const_iterator | const_iterator |
Protected Member Functions | |
| iterator | find (T elem) |
Protected Attributes | |
| std::list< std::pair< int, T > > | contents |
Maintains a list of elements ordered according to access frequency.
|
protected |
|
protected |
|
inline |
Accessess element (possibly new), increasing its access count.

|
inline |
Returns true if the list is non-empty.
|
inlineprotected |
|
inline |
Returns an ordered list of the k most frequently accessed elements.
|
inline |
Removes the given element from the list of favorites (if found)

|
inline |
Returns number of distinct elements in the list.
|
protected |