ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::containers::detail::RecyclerPrivate< TAllocator, TNode > Struct Template Reference

Description:

template<typename TAllocator, typename TNode>
struct alib::containers::detail::RecyclerPrivate< TAllocator, TNode >

Implements internal recycling interface. Used by container types of module ALib Containers that use private recycling (when their template parameter TRecycling evaluates to Private).

Template Parameters
TAllocatorThe allocator to store and use.
TNodeThe type to recycle. Has to be derived of lang::SidiNodeBase.

Definition at line 244 of file recycling.inl.

Inheritance diagram for alib::containers::detail::RecyclerPrivate< TAllocator, TNode >:
[legend]
Collaboration diagram for alib::containers::detail::RecyclerPrivate< TAllocator, TNode >:
[legend]

Public Static Method Index:

static constexpr bool IsRecycling () noexcept
 

Public Method Index:

 RecyclerPrivate () noexcept=default
 Parameterless constructor. Used with type HeapAllocator.
 
 RecyclerPrivate (const RecyclerPrivate &copy) noexcept
 
 RecyclerPrivate (RecyclerPrivate &&move) noexcept
 
 RecyclerPrivate (TAllocator &pAllocator) noexcept
 
 ~RecyclerPrivate () noexcept
 Destructor. Frees all recyclables with the allocator.
 
lang::AllocatorInterface< TAllocator > AI () const noexcept
 
integer Count () const noexcept
 
template<typename TChunk>
void DisposeChunk (TChunk *chunk, size_t length) noexcept
 
void DisposeList (TNode *begin) noexcept
 
void DisposeList (TNode *begin, TNode *end) noexcept
 
TNode * Get ()
 
TAllocator & GetAllocator () const noexcept
 
void Recycle (TNode *elem) noexcept
 
template<typename TChunk>
void RecycleChunk (TChunk *chunk, size_t length) noexcept
 
void RecycleList (TNode *begin) noexcept
 
std::pair< TNode *, integerRecycleList (TNode *begin, TNode *end) noexcept
 
void Reserve (integer qty) noexcept
 
void Reset () noexcept
 Resets this recycler. Frees all recyclables with the allocator.
 
- Public Method Index: inherited from alib::lang::AllocatorMember< TAllocator >
 AllocatorMember ()=delete
 Deleted default constructor. (The allocator has to be given with construction)
 
 AllocatorMember (TAllocator &pAllocator) noexcept
 
AllocatorInterface< TAllocator > AI () const noexcept
 
TAllocator & GetAllocator () const noexcept
 

Protected Type Index:

using base = lang::AllocatorMember<TAllocator>
 The base type.
 

Protected Field Index:

lang::SidiListHook< TNode > recyclables
 The list of recyclables.
 
- Protected Field Index: inherited from alib::lang::AllocatorMember< TAllocator >
TAllocator & allocator
 A reference to the allocator.
 

Additional Inherited Members

- Public Type Index: inherited from alib::lang::AllocatorMember< TAllocator >
using AllocatorType = TAllocator
 Exposes the allocator type.
 

Type Definition Details:

◆ base

template<typename TAllocator, typename TNode>
using alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::base = lang::AllocatorMember<TAllocator>
protected

The base type.

Definition at line 248 of file recycling.inl.

Field Details:

◆ recyclables

template<typename TAllocator, typename TNode>
lang::SidiListHook<TNode> alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::recyclables
protected

The list of recyclables.

Definition at line 251 of file recycling.inl.

Constructor(s) / Destructor Details:

◆ RecyclerPrivate() [1/3]

template<typename TAllocator, typename TNode>
alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::RecyclerPrivate ( TAllocator & pAllocator)
inlineexplicitnoexcept

Constructor taking an allocator.

Parameters
pAllocatorThe allocator to use.

Definition at line 260 of file recycling.inl.

Here is the call graph for this function:

◆ RecyclerPrivate() [2/3]

template<typename TAllocator, typename TNode>
alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::RecyclerPrivate ( const RecyclerPrivate< TAllocator, TNode > & copy)
inlinenoexcept

Copy constructor. Does not copy the recycle node, but clears this one.

Parameters
copyThe object to copy.

Definition at line 265 of file recycling.inl.

Here is the call graph for this function:

◆ RecyclerPrivate() [3/3]

template<typename TAllocator, typename TNode>
alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::RecyclerPrivate ( RecyclerPrivate< TAllocator, TNode > && move)
inlinenoexcept

Move constructor. Grabs the recyclables from the moved one and sets moved to nulled.

Parameters
moveThe private recycler to move.

Definition at line 270 of file recycling.inl.

Here is the call graph for this function:

◆ ~RecyclerPrivate()

template<typename TAllocator, typename TNode>
alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::~RecyclerPrivate ( )
inlinenoexcept

Destructor. Frees all recyclables with the allocator.

Definition at line 278 of file recycling.inl.

Here is the call graph for this function:

Method Details:

◆ AI()

template<typename TAllocator, typename TNode>
lang::AllocatorInterface< TAllocator > alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::AI ( ) const
inlinenoexcept
Returns
The allocator interface of the allocator received with construction.

Definition at line 303 of file recycling.inl.

Here is the call graph for this function:

◆ Count()

template<typename TAllocator, typename TNode>
integer alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::Count ( ) const
inlinenodiscardnoexcept

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

Returns
The number of available elements.

Definition at line 312 of file recycling.inl.

◆ DisposeChunk()

template<typename TAllocator, typename TNode>
template<typename TChunk>
void alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::DisposeChunk ( TChunk * chunk,
size_t length )
inlinenoexcept

Frees the given memory. Note that the shared recycler calls RecycleChunk with this method.

Template Parameters
TChunkThe type of array that is to be freed.
Parameters
chunkThe chunk array to convert into nodes
lengthThe length of the chunk array (pass 1 if the chunk is not an array type).

Definition at line 378 of file recycling.inl.

Here is the call graph for this function:

◆ DisposeList() [1/2]

template<typename TAllocator, typename TNode>
void alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::DisposeList ( TNode * begin)
inlinenoexcept

Deletes the given list. This shared recycler does not free the node, but recycles them.

Parameters
beginThe first element of the list to free.

Definition at line 345 of file recycling.inl.

Here is the call graph for this function:

◆ DisposeList() [2/2]

template<typename TAllocator, typename TNode>
void alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::DisposeList ( TNode * begin,
TNode * end )
inlinenoexcept

Deletes a list of elements for recycling. Both given nodes have to exist.

Parameters
beginThe first element of the list to free.
endThe first element not to be freed.

Definition at line 350 of file recycling.inl.

Here is the call graph for this function:

◆ Get()

template<typename TAllocator, typename TNode>
TNode * alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::Get ( )
inlinenodiscard

Returns a recycled object or allocates a new one.

Returns
A recycled or allocated element.

Definition at line 322 of file recycling.inl.

Here is the call graph for this function:

◆ GetAllocator()

template<typename TAllocator, typename TNode>
TAllocator & alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::GetAllocator ( ) const
inlinenoexcept
Returns
Returns the allocator received with construction.

Definition at line 300 of file recycling.inl.

Here is the call graph for this function:

◆ IsRecycling()

template<typename TAllocator, typename TNode>
constexpr bool alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::IsRecycling ( )
inlinestaticconstexprnoexcept
Returns
Returns true to indicate that this is not a non-recycling version.

Definition at line 306 of file recycling.inl.

◆ Recycle()

template<typename TAllocator, typename TNode>
void alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::Recycle ( TNode * elem)
inlinenoexcept

Stores an element for recycling.

Parameters
elemThe element to store.

Definition at line 328 of file recycling.inl.

Here is the call graph for this function:

◆ RecycleChunk()

template<typename TAllocator, typename TNode>
template<typename TChunk>
void alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::RecycleChunk ( TChunk * chunk,
size_t length )
inlinenoexcept

Converts a given chunk of memory, previously allocated with the same allocator that this type uses, into recyclable node objects.
This is only done if Allocator::allowsMemSplit returns true.

Template Parameters
TChunkThe type of array that is to be cut into node elements.
Parameters
chunkThe chunk array to convert into nodes
lengthThe length of the chunk array (pass 1 if the chunk is not an array type).

Definition at line 361 of file recycling.inl.

Here is the call graph for this function:

◆ RecycleList() [1/2]

template<typename TAllocator, typename TNode>
void alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::RecycleList ( TNode * begin)
inlinenoexcept

Stores a list of elements for recycling (from the begin element to the last one).

Parameters
beginThe first element of the list store, must not be nullptr.

Definition at line 332 of file recycling.inl.

Here is the call graph for this function:

◆ RecycleList() [2/2]

template<typename TAllocator, typename TNode>
std::pair< TNode *, integer > alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::RecycleList ( TNode * begin,
TNode * end )
inlinenoexcept

Stores a list of elements for recycling. Both given nodes have to exist.

Parameters
beginThe first element of the list to recycle.
endThe first element not to be recycled.
Returns
A pair of values. The first is a pointer to the last node recycled, and the second provides the number of nodes recycled.

Definition at line 339 of file recycling.inl.

Here is the call graph for this function:

◆ Reserve()

template<typename TAllocator, typename TNode>
void alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::Reserve ( integer qty)
inlinenoexcept

Reserves the given number of recyclables.

Parameters
qtyThe number of new recyclables to allocate.

Definition at line 317 of file recycling.inl.

Here is the call graph for this function:

◆ Reset()

template<typename TAllocator, typename TNode>
void alib::containers::detail::RecyclerPrivate< TAllocator, TNode >::Reset ( )
inlinenoexcept

Resets this recycler. Frees all recyclables with the allocator.

Definition at line 290 of file recycling.inl.

Here is the call graph for this function:

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