BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslstl::TreeNodePool< VALUE, ALLOCATOR > Class Template Reference

#include <bslstl_treenodepool.h>

Public Types

typedef Pool::AllocatorType AllocatorType
 Alias for the allocator type defined by SimplePool.
 
typedef AllocatorTraits::size_type size_type
 Alias for the size_type of the allocator defined by SimplePool.
 

Public Member Functions

 TreeNodePool (const ALLOCATOR &allocator)
 
 TreeNodePool (bslmf::MovableRef< TreeNodePool > original)
 
void adopt (bslmf::MovableRef< TreeNodePool > pool)
 
AllocatorTypeallocator ()
 
bslalg::RbTreeNodecloneNode (const bslalg::RbTreeNode &original)
 
template<class... Args>
bslalg::RbTreeNodeemplaceIntoNewNode (Args &&... args)
 
void deleteNode (bslalg::RbTreeNode *node)
 
bslalg::RbTreeNodemoveIntoNewNode (bslalg::RbTreeNode *original)
 
void reserveNodes (size_type numNodes)
 
void swap (TreeNodePool &other)
 
void swapExchangeAllocators (TreeNodePool &other)
 
void swapRetainAllocators (TreeNodePool &other)
 
const AllocatorTypeallocator () const
 
bool hasFreeNodes () const
 

Detailed Description

template<class VALUE, class ALLOCATOR>
class bslstl::TreeNodePool< VALUE, ALLOCATOR >

This class provides methods for creating and deleting nodes using the appropriate allocator traits of the (template parameter) type ALLOCATOR. This type is intended to be used as a private base-class for a node-based container, in order to take advantage of the empty-base-class optimization in the case where the base class has 0 size (as may be the case if the (template parameter) type ALLOCATOR is not a bslma::Allocator).

See bslstl_treenodepool

Member Typedef Documentation

◆ AllocatorType

template<class VALUE , class ALLOCATOR >
typedef Pool::AllocatorType bslstl::TreeNodePool< VALUE, ALLOCATOR >::AllocatorType

◆ size_type

template<class VALUE , class ALLOCATOR >
typedef AllocatorTraits::size_type bslstl::TreeNodePool< VALUE, ALLOCATOR >::size_type

Constructor & Destructor Documentation

◆ TreeNodePool() [1/2]

template<class VALUE , class ALLOCATOR >
bslstl::TreeNodePool< VALUE, ALLOCATOR >::TreeNodePool ( const ALLOCATOR &  allocator)
inlineexplicit

Create a node-pool that will use the specified allocator to supply memory for allocated node objects.

◆ TreeNodePool() [2/2]

template<class VALUE , class ALLOCATOR >
bslstl::TreeNodePool< VALUE, ALLOCATOR >::TreeNodePool ( bslmf::MovableRef< TreeNodePool< VALUE, ALLOCATOR > >  original)
inline

Create a node-pool, adopting all outstanding memory allocations associated with the specified original node-pool, that will use the allocator associated with original to supply memory for allocated node objects. original is left in a valid but unspecified state.

Member Function Documentation

◆ adopt()

template<class VALUE , class ALLOCATOR >
void bslstl::TreeNodePool< VALUE, ALLOCATOR >::adopt ( bslmf::MovableRef< TreeNodePool< VALUE, ALLOCATOR > >  pool)
inline

Adopt all outstanding memory allocations associated with the specified node pool. The behavior is undefined unless this pool uses the same allocator as that associated with pool. The behavior is also undefined unless this pool is in the default-constructed state.

◆ allocator() [1/2]

template<class VALUE , class ALLOCATOR >
SimplePool< TreeNode< VALUE >, ALLOCATOR >::AllocatorType & bslstl::TreeNodePool< VALUE, ALLOCATOR >::allocator ( )
inline

Return a reference providing modifiable access to the rebound allocator traits for the node-type. Note that this operation returns a base-class (NodeAlloc) reference to this object.

◆ allocator() [2/2]

template<class VALUE , class ALLOCATOR >
const SimplePool< TreeNode< VALUE >, ALLOCATOR >::AllocatorType & bslstl::TreeNodePool< VALUE, ALLOCATOR >::allocator ( ) const
inline

Return a reference providing non-modifiable access to the rebound allocator traits for the node-type. Note that this operation returns a base-class (NodeAlloc) reference to this object.

◆ cloneNode()

template<class VALUE , class ALLOCATOR >
bslalg::RbTreeNode * bslstl::TreeNodePool< VALUE, ALLOCATOR >::cloneNode ( const bslalg::RbTreeNode original)
inline

Allocate a node object and copy-construct an object of the (template parameter) type VALUE having the same value as the specified original at the value attribute of the node. Return the address of the newly allocated node. The behavior is undefined unless original refers to a TreeNode<VALUE> object holding a valid (initialized) value.

◆ deleteNode()

template<class VALUE , class ALLOCATOR >
void bslstl::TreeNodePool< VALUE, ALLOCATOR >::deleteNode ( bslalg::RbTreeNode node)
inline

Destroy the VALUE value of the specified node and return the memory footprint of node to this pool for potential reuse. The behavior is undefined unless node refers to a TreeNode<VALUE>.

◆ emplaceIntoNewNode()

template<class VALUE , class ALLOCATOR >
template<class... Args>
bslalg::RbTreeNode * bslstl::TreeNodePool< VALUE, ALLOCATOR >::emplaceIntoNewNode ( Args &&...  args)
inline

Allocate a node with a newly created value object of the (template parameter) type VALUE, constructed by forwarding allocator() and the specified (variable number of) arguments to the corresponding constructor of VALUE. Return the address of the newly allocated node. This operation requires that VALUE be constructible from arguments.

◆ hasFreeNodes()

template<class VALUE , class ALLOCATOR >
bool bslstl::TreeNodePool< VALUE, ALLOCATOR >::hasFreeNodes ( ) const
inline

Return true if this object holds free (currently unused) nodes, and false otherwise.

◆ moveIntoNewNode()

template<class VALUE , class ALLOCATOR >
bslalg::RbTreeNode * bslstl::TreeNodePool< VALUE, ALLOCATOR >::moveIntoNewNode ( bslalg::RbTreeNode original)
inline

Allocate a node of the type TreeNode<VALUE>, and move-construct an object of the (template parameter) type VALUE with the (explicitly moved) value indicated by the value attribute of the specified original node. Return the address of the newly allocated node. The object referred to by the value attribute of original is left in a valid but unspecified state. The behavior is undefined unless original refers to a TreeNode<VALUE> object holding a valid (initialized) value.

◆ reserveNodes()

template<class VALUE , class ALLOCATOR >
void bslstl::TreeNodePool< VALUE, ALLOCATOR >::reserveNodes ( size_type  numNodes)
inline

Add to this pool sufficient memory to satisfy memory requests for at least the specified numNodes. The additional memory is added irrespective of the amount of free memory when called. The behavior is undefined unless 0 < numNodes.

◆ swap()

template<class VALUE , class ALLOCATOR >
void bslstl::TreeNodePool< VALUE, ALLOCATOR >::swap ( TreeNodePool< VALUE, ALLOCATOR > &  other)
inline

Efficiently exchange the nodes of this object with those of the specified other object. This method provides the no-throw exception-safety guarantee. The behavior is undefined unless allocator() == other.allocator().

◆ swapExchangeAllocators()

template<class VALUE , class ALLOCATOR >
void bslstl::TreeNodePool< VALUE, ALLOCATOR >::swapExchangeAllocators ( TreeNodePool< VALUE, ALLOCATOR > &  other)
inline

Efficiently exchange the nodes and allocator of this object with those of the specified other object. This method provides the no-throw exception-safety guarantee, unless swapping the (user-supplied) allocator objects can throw.

◆ swapRetainAllocators()

template<class VALUE , class ALLOCATOR >
void bslstl::TreeNodePool< VALUE, ALLOCATOR >::swapRetainAllocators ( TreeNodePool< VALUE, ALLOCATOR > &  other)
inline

Efficiently exchange the nodes of this object with those of the specified other object. This method provides the no-throw exception-safety guarantee. The behavior is undefined unless allocator() == other.allocator().


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