Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template node_allocator

boost::container::node_allocator

Synopsis

// In header: <boost/container/node_allocator.hpp>

template<typename T,  NodesPerBlock = NodeAlloc_nodes_per_block> 
class node_allocator {
public:
  // types
  typedef unsigned int                                                                            ;           
  typedef node_allocator< T, NodesPerBlock, Version >                                             ;                    
  typedef T                                                                                       ;                
  typedef T *                                                                                     ;                   
  typedef const T *                                                                               ;             
  typedef ::T >::                                          ;                 
  typedef ::constT >::                                     ;           
  typedef                                                                              ;                 
  typedef                                                                           ;           
  typedef self_t,(unsigned int) Version >                    ;                   
  typedef void * >                            ;
  typedef T > ;     

  // member classes/structs/unions
  template<typename T,  NodesPerBlock = NodeAlloc_nodes_per_block> 
  struct rebind {
    // types
    typedef node_allocator< T2, NodesPerBlock, Version > ;
  };

  // construct/copy/destruct
  ();
  (const node_allocator &);
  template<typename T2> 
    (const node_allocator< T2, NodesPerBlock ifndef BOOST_CONTAINER_DOXYGEN_INVOKED, Version endif > &);
  template<typename T2,  N2> 
    node_allocator & (const node_allocator< T2, N2 > &);
  ~();

  // public member functions
   ((Version<=);
   () ;
  pointer (, const void * = );
  void (const pointer &, );
  pointer (, , , 
                             pointer &);
   (pointer) ;
  pointer ();
  void (, );
  void (pointer);
  void ();
  void (, , );
  void (const , , );
  void ();

  // private member functions
  pointer (, , , 
                                  pointer &);

  // public static functions
  void ();

  // friend functions
  void (self_t &, self_t &);
  bool (const node_allocator &, const node_allocator &);
  bool (const node_allocator &, const node_allocator &);

  // public data members
  static const  nodes_per_block;
};

Description

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 types

  1. typedef unsigned int ;

    If Version is 1, the allocator is a STL conforming allocator. If Version is 2, the allocator offers advanced expand in place and burst allocation capabilities.

node_allocator public construct/copy/destruct

  1. ();
    Default constructor.
  2. (const node_allocator &);
    Copy constructor from other node_allocator.
  3. template<typename T2> 
      (const node_allocator< T2, NodesPerBlock ifndef BOOST_CONTAINER_DOXYGEN_INVOKED, Version endif > &);
    Copy constructor from related node_allocator.
  4. template<typename T2,  N2> 
      node_allocator & (const node_allocator< T2, N2 > &);
    Not assignable from related node_allocator.
  5. ~();
    Destructor.

node_allocator public member functions

  1.  ((Version<=);
  2.  () ;

    Returns the number of elements that could be allocated. Never throws

  3. pointer ( count, const void * = );

    Allocate memory for an array of count elements. Throws bad_alloc if there is no enough memory

  4. void (const pointer & ptr,  count);

    Deallocate allocated memory. Never throws

  5. pointer ( command,  limit_size, 
                                prefer_in_recvd_out_size, 
                               pointer & reuse);
  6.  (pointer p) ;

    Returns maximum the number of objects the previously allocated memory pointed by p can hold.

  7. pointer ();

    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

  8. void ( num_elements, 
                              chain);

    Allocates many elements of size == 1. Elements must be individually deallocated with deallocate_one()

  9. void (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

  10. void ( chain);
  11. void ( elem_size,  n_elements, 
                        chain);

    Allocates many elements of size elem_size. Elements must be individually deallocated with deallocate()

  12. void (const  elem_sizes,  n_elements, 
                        chain);

    Allocates n_elements elements, each one of size elem_sizes[i] Elements must be individually deallocated with deallocate()

  13. void ( chain);

node_allocator private member functions

  1. pointer ( command, 
                                     limit_size, 
                                     prefer_in_recvd_out_size, 
                                    pointer & reuse);

node_allocator public static functions

  1. void ();
    Deallocates all free blocks of the pool.

node_allocator friend functions

  1. void (self_t &, self_t &);

    Swaps allocators. Does not throw. If each allocator is placed in a different memory segment, the result is undefined.

  2. bool (const node_allocator &, const node_allocator &);

    An allocator always compares to true, as memory allocated with one instance can be deallocated by another instance

  3. bool (const node_allocator &, const node_allocator &);

    An allocator always compares to false, as memory allocated with one instance can be deallocated by another instance


PrevUpHomeNext