Data Structures & Algorithms in C++
Goodrich, Tamassia, Mount and Goldwasser
Loading...
Searching...
No Matches
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
dsac::list::FavoritesList< T > Class Template Reference

Maintains a list of elements ordered according to access frequency. More...

#include <favorites_list.h>

Inheritance diagram for dsac::list::FavoritesList< T >:
Inheritance graph
Collaboration diagram for dsac::list::FavoritesList< T >:
Collaboration graph

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
 

Detailed Description

template<typename T>
class dsac::list::FavoritesList< T >

Maintains a list of elements ordered according to access frequency.

Member Typedef Documentation

◆ const_iterator

template<typename T >
typedef std::list<std::pair<int,T>>::const_iterator dsac::list::FavoritesList< T >::const_iterator
protected

◆ iterator

template<typename T >
typedef std::list<std::pair<int,T>>::iterator dsac::list::FavoritesList< T >::iterator
protected

Member Function Documentation

◆ access()

template<typename T >
void dsac::list::FavoritesList< T >::access ( elem)
inline

Accessess element (possibly new), increasing its access count.

Here is the call graph for this function:

◆ empty()

template<typename T >
bool dsac::list::FavoritesList< T >::empty ( ) const
inline

Returns true if the list is non-empty.

◆ find()

template<typename T >
iterator dsac::list::FavoritesList< T >::find ( elem)
inlineprotected

◆ get_favorites()

template<typename T >
std::list< T > dsac::list::FavoritesList< T >::get_favorites ( int  k) const
inline

Returns an ordered list of the k most frequently accessed elements.

◆ remove()

template<typename T >
void dsac::list::FavoritesList< T >::remove ( elem)
inline

Removes the given element from the list of favorites (if found)

Here is the call graph for this function:

◆ size()

template<typename T >
int dsac::list::FavoritesList< T >::size ( ) const
inline

Returns number of distinct elements in the list.

Field Documentation

◆ contents

template<typename T >
std::list<std::pair<int,T> > dsac::list::FavoritesList< T >::contents
protected

The documentation for this class was generated from the following file: