Home | Libraries | People | FAQ | More |
boost::container::node_allocator
// In header: <boost/container/node_allocator.hpp> template<typename T, std::size_t NodesPerBlock = NodeAlloc_nodes_per_block> class node_allocator { public: // types typedef unsigned int allocation_type; typedef node_allocator< T, NodesPerBlock, Version > self_t; typedef T value_type; typedef T * pointer; typedef const T * const_pointer; typedef ::boost::container::dtl::unvoid_ref< T >::type reference; typedef ::boost::container::dtl::unvoid_ref< constT >::type const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef boost::container::dtl::version_type< self_t, Version > version; typedef boost::container::dtl::basic_multiallocation_chain< void * > multiallocation_chain_void; typedef boost::container::dtl::transform_multiallocation_chain< multiallocation_chain_void, T > multiallocation_chain; // member classes/structs/unions template<typename T, std::size_t NodesPerBlock = NodeAlloc_nodes_per_block> struct rebind { // types typedef node_allocator< T2, NodesPerBlock, Version > other; }; // construct/copy/destruct node_allocator(); node_allocator(const node_allocator &); template<typename T2> node_allocator(const node_allocator< T2, NodesPerBlock #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED, Version #endif > &); template<typename T2, std::size_t N2> node_allocator & operator=(const node_allocator< T2, N2 > &); ~node_allocator(); // public member functions BOOST_STATIC_ASSERT((Version<=2)); size_type max_size() const; pointer allocate(size_type, const void * = 0); void deallocate(const pointer &, size_type); pointer allocation_command(allocation_type, size_type, size_type &, pointer &); size_type size(pointer) const; pointer allocate_one(); void allocate_individual(std::size_t, multiallocation_chain &); void deallocate_one(pointer); void deallocate_individual(multiallocation_chain &); void allocate_many(size_type, std::size_t, multiallocation_chain &); void allocate_many(const size_type *, size_type, multiallocation_chain &); void deallocate_many(multiallocation_chain &); // private member functions pointer priv_allocation_command(allocation_type, std::size_t, size_type &, pointer &); // public static functions static void deallocate_free_blocks(); // friend functions void swap(self_t &, self_t &); bool operator==(const node_allocator &, const node_allocator &); bool operator!=(const node_allocator &, const node_allocator &); // public data members static const std::size_t nodes_per_block; };
An STL node allocator that uses a modified DlMalloc as memory source.
This node allocator shares a segregated storage between all instances of node_allocator with equal sizeof(T).
NodesPerBlock is the number of nodes allocated at once when the allocator runs out of nodes
node_allocator
public
construct/copy/destructnode_allocator();Default constructor.
node_allocator(const node_allocator &);Copy constructor from other
node_allocator
. template<typename T2> node_allocator(const node_allocator< T2, NodesPerBlock #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED, Version #endif > &);Copy constructor from related
node_allocator
. template<typename T2, std::size_t N2> node_allocator & operator=(const node_allocator< T2, N2 > &);Not assignable from related
node_allocator
. ~node_allocator();Destructor.
node_allocator
public member functionsBOOST_STATIC_ASSERT((Version<=2));
size_type max_size() const;
Returns the number of elements that could be allocated. Never throws
pointer allocate(size_type count, const void * = 0);
Allocate memory for an array of count elements. Throws std::bad_alloc if there is no enough memory
void deallocate(const pointer & ptr, size_type count);
Deallocate allocated memory. Never throws
pointer allocation_command(allocation_type command, size_type limit_size, size_type & prefer_in_recvd_out_size, pointer & reuse);
size_type size(pointer p) const;
Returns maximum the number of objects the previously allocated memory pointed by p can hold.
pointer allocate_one();
Allocates just one object. Memory allocated with this function must be deallocated only with deallocate_one(). Throws bad_alloc if there is no enough memory
void allocate_individual(std::size_t num_elements, multiallocation_chain & chain);
Allocates many elements of size == 1. Elements must be individually deallocated with deallocate_one()
void deallocate_one(pointer p);
Deallocates memory previously allocated with allocate_one(). You should never use deallocate_one to deallocate memory allocated with other functions different from allocate_one(). Never throws
void deallocate_individual(multiallocation_chain & chain);
void allocate_many(size_type elem_size, std::size_t n_elements, multiallocation_chain & chain);
Allocates many elements of size elem_size. Elements must be individually deallocated with deallocate()
void allocate_many(const size_type * elem_sizes, size_type n_elements, multiallocation_chain & chain);
Allocates n_elements elements, each one of size elem_sizes[i] Elements must be individually deallocated with deallocate()
void deallocate_many(multiallocation_chain & chain);
node_allocator
friend functionsvoid swap(self_t &, self_t &);
Swaps allocators. Does not throw. If each allocator is placed in a different memory segment, the result is undefined.
bool operator==(const node_allocator &, const node_allocator &);
An allocator always compares to true, as memory allocated with one instance can be deallocated by another instance
bool operator!=(const node_allocator &, const node_allocator &);
An allocator always compares to false, as memory allocated with one instance can be deallocated by another instance