libboxes
boxes is a set of specialised containers built on top of STL
Public Member Functions | List of all members
boxes::cache::policy::LFU< K, V > Class Template Reference

Eviction policy that evicts the least frequently used element. More...

#include <cache.hpp>

Public Member Functions

void clear ()
 Clears the eviction policy. More...
 
K & front ()
 Returns the reference to the first element in the cache. More...
 
K & back ()
 Returns the reference to the last element in the cache. More...
 
Iterator begin ()
 Returns an iterator to the first element in the cache. More...
 
Iterator end ()
 Returns an iterator to the element following the last element in the cache. More...
 
const K * elect ()
 Elects the least frequently used element for eviction. More...
 

Detailed Description

template<typename K, typename V>
class boxes::cache::policy::LFU< K, V >

Eviction policy that evicts the least frequently used element.

The order of elements in the cache is defined by the frequency of access. The most frequently used element (and least likely to be evicted) is stored at the front of the queue.

Definition at line 238 of file cache.hpp.

Member Function Documentation

◆ back()

template<typename K , typename V >
K & boxes::cache::policy::LFU< K, V >::back ( )
inline

Returns the reference to the last element in the cache.

Last element is the least frequently used element.

Returns
least frequently used element

Definition at line 288 of file cache.hpp.

◆ begin()

template<typename K , typename V >
Iterator boxes::cache::policy::LFU< K, V >::begin ( )
inline

Returns an iterator to the first element in the cache.

First element is the most frequently used element.

Returns
iterator to the first element in the cache

Definition at line 297 of file cache.hpp.

◆ clear()

template<typename K , typename V >
void boxes::cache::policy::LFU< K, V >::clear ( )
inline

Clears the eviction policy.

Definition at line 253 of file cache.hpp.

◆ elect()

template<typename K , typename V >
const K * boxes::cache::policy::LFU< K, V >::elect ( )
inline

Elects the least frequently used element for eviction.

Returns
pointer to the least frequently used element, or nullptr if no eviction is needed

Definition at line 313 of file cache.hpp.

◆ end()

template<typename K , typename V >
Iterator boxes::cache::policy::LFU< K, V >::end ( )
inline

Returns an iterator to the element following the last element in the cache.

Returns
iterator to the element following the last element in the cache

Definition at line 305 of file cache.hpp.

◆ front()

template<typename K , typename V >
K & boxes::cache::policy::LFU< K, V >::front ( )
inline

Returns the reference to the first element in the cache.

First element is the most frequently used element.

Returns
most frequently used element

Definition at line 279 of file cache.hpp.


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