Dune::PoolAllocator< T, s > Class Template Reference
[Common]
#include <poolallocator.hh>
Detailed Description
template<class T, std::size_t s>
class Dune::PoolAllocator< T, s >
An allocator managing a pool of objects for reuse.
This allocator is specifically useful for small data types where new and delete are too expensive.
- Warning:
- It is not suitable for the use in standard containers as it cannot allocate arrays of arbituary size
Public Types | |
enum | { size = s } |
typedef T | value_type |
Type of the values we construct and allocate. | |
typedef T * | pointer |
The pointer type. | |
typedef const T * | const_pointer |
The constant pointer type. | |
typedef T & | reference |
The reference type. | |
typedef const T & | const_reference |
The constant reference type. | |
typedef std::size_t | size_type |
The size type. | |
typedef std::ptrdiff_t | difference_type |
The difference_type. | |
Public Member Functions | |
PoolAllocator () | |
Constructor. | |
template<typename U, std::size_t u> | |
PoolAllocator (const PoolAllocator< U, u > &) | |
Coopy Constructor. | |
pointer | allocate (size_t n, const_pointer hint=0) |
Allocates objects. | |
void | deallocate (pointer p, std::size_t n) |
Free objects. | |
void | construct (pointer p, const_reference value) |
Construct an object. | |
void | destroy (pointer p) |
Destroy an object without freeing memory. | |
pointer | address (reference x) const |
Convert a reference to a pointer. | |
const_pointer | address (const_reference x) const |
Convert a reference to a pointer. | |
int | max_size () const throw () |
Not correctly implemented, yet! | |
Classes | |
struct | rebind |
Rebind the allocator to another type. More... |
Member Enumeration Documentation
template<class T, std::size_t s>
anonymous enum |
Member Function Documentation
template<class T, std::size_t s>
pointer Dune::PoolAllocator< T, s >::allocate | ( | size_t | n, | |
const_pointer | hint = 0 | |||
) | [inline] |
Allocates objects.
- Parameters:
-
n The number of objects to allocate. Has to be less than Pool<T,s>::elements! hint Ignored hint.
- Returns:
- A pointer tp the allocated elements.
The documentation for this class was generated from the following file: