MySQL 9.0.0
Source Code Documentation
dd::cache::Free_list< E > Class Template Reference

Template for management of a free list based on a std::vector. More...

#include <free_list.h>

Public Member Functions

 Free_list ()
 
size_t length () const
 
void add_last (E *element)
 Add an element to the end of the free list. More...
 
void remove (E *element)
 Remove an element from the free list. More...
 
E * get_lru () const
 Get the least recently used element in the list, i.e., the first element. More...
 
void dump () const
 Debug dump of the free list to stderr. More...
 

Private Types

typedef std::vector< E *, Malloc_allocator< E * > > List_type
 

Private Attributes

List_type m_list
 

Detailed Description

template<typename E>
class dd::cache::Free_list< E >

Template for management of a free list based on a std::vector.

The free list template defines functions mostly wrapping the std::vector functions, but additionally doing some asserts to ensure correct usage.

The first element in the free list is the least recently used element. When a new element becomes unused, it is added to the end of the free list. An element may also be removed from within the middle of the free list when the element is being acquired. This use case means iterating through the vector to find the correct element.

Template Parameters
EElement type (a Cache_element wrapping some dictionary object type).

Member Typedef Documentation

◆ List_type

template<typename E >
typedef std::vector<E *, Malloc_allocator<E *> > dd::cache::Free_list< E >::List_type
private

Constructor & Destructor Documentation

◆ Free_list()

template<typename E >
dd::cache::Free_list< E >::Free_list ( )
inline

Member Function Documentation

◆ add_last()

template<typename E >
void dd::cache::Free_list< E >::add_last ( E *  element)
inline

Add an element to the end of the free list.

Parameters
elementElement to add to the end of the list.

◆ dump()

template<typename E >
void dd::cache::Free_list< E >::dump ( ) const
inline

Debug dump of the free list to stderr.

◆ get_lru()

template<typename E >
E * dd::cache::Free_list< E >::get_lru ( ) const
inline

Get the least recently used element in the list, i.e., the first element.

Returns
The least recently used element in the list.

◆ length()

template<typename E >
size_t dd::cache::Free_list< E >::length ( ) const
inline

◆ remove()

template<typename E >
void dd::cache::Free_list< E >::remove ( E *  element)
inline

Remove an element from the free list.

Parameters
elementElement to be removed from the list.

Member Data Documentation

◆ m_list

template<typename E >
List_type dd::cache::Free_list< E >::m_list
private

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