ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
RecyclerPSBase< TSidiNode, TList > Struct Template Reference

Description:

template<typename TSidiNode, typename TList>
struct alib::monomem::detail::RecyclerPSBase< TSidiNode, TList >

This struct is used for recycling of "node elements" which are derived of type lang::SidiNodeBase . This class provides the common base for detail::RecyclerPrivate and detail::RecyclerShared .

Template Parameters
TSidiNodeThe type to recycle. Has to be derived of lang::SidiNodeBase .
TListThe type of the list of recyclables: Either the same as TSidiNode or a reference to it.

Definition at line 59 of file recycler.inl.

Public Method Index:

 RecyclerPSBase ()=default
 
 RecyclerPSBase (TList sharedRecyclables)
 
integer count () const
 
TSidiNode * get ()
 
void recycle (TSidiNode *elem)
 
void recycle (TSidiNode *first, TSidiNode *last)
 
template<typename TChunk >
void recycleChunk (TChunk *chunk, size_t count)
 

Field Details:

◆ recyclables

template<typename TSidiNode , typename TList >
TList recyclables
protected

The list of recyclables.

Definition at line 63 of file recycler.inl.

Constructor(s) / Destructor Details::

◆ RecyclerPSBase() [1/2]

template<typename TSidiNode , typename TList >
RecyclerPSBase ( )
default

Empty constructor, used by derived type detail::RecyclerPrivate .

◆ RecyclerPSBase() [2/2]

template<typename TSidiNode , typename TList >
RecyclerPSBase ( TList sharedRecyclables)
inline

Empty constructor, used by derived type detail::RecyclerShared .

Parameters
sharedRecyclablesThe external list of recyclables.

Definition at line 73 of file recycler.inl.

Method Details:

◆ count()

template<typename TSidiNode , typename TList >
integer count ( ) const
inline

Counts the number of recyclables.
Attention: This method runs in linear time.

Returns
The number of available elements.

Definition at line 164 of file recycler.inl.

◆ get()

template<typename TSidiNode , typename TList >
TSidiNode * get ( )
inline

Returns a stored element. If no elements are available, nullptr is returned.

Returns
A recycled element or nullptr if no recyclables are available.

Definition at line 156 of file recycler.inl.

◆ recycle() [1/2]

template<typename TSidiNode , typename TList >
void recycle ( TSidiNode * elem)
inline

Stores an element for recycling.

Parameters
elemThe element to store.

Definition at line 79 of file recycler.inl.

◆ recycle() [2/2]

template<typename TSidiNode , typename TList >
void recycle ( TSidiNode * first,
TSidiNode * last )
inline

Stores a list of elements for recycling.

Parameters
firstThe first element of the list store.
lastThe last element of the list store.

Definition at line 87 of file recycler.inl.

◆ recycleChunk()

template<typename TSidiNode , typename TList >
template<typename TChunk >
void recycleChunk ( TChunk * chunk,
size_t count )
inline

Recycles a chunk of memory that is not of the node type. Such recycling is useful for example, in combination with hash tables, which usually allocate a "bucket array" that grows over time. In this case, the former smaller bucket array may be passed to this method to recycle it as future node elements.

Template Parameters
TChunkThe type of the chunk.
Parameters
chunkThe recyclable chunk's address.
countThe number of objects (1 for non-array types, >1 for arrays.

Definition at line 100 of file recycler.inl.

Here is the call graph for this function:

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