Loading...
Searching...
No Matches
Dune::PoolAllocator< T, s > Class Template Reference
Common » Allocators

An allocator managing a pool of objects for reuse. More...

`#include <dune/common/poolallocator.hh>`

Inheritance diagram for Dune::PoolAllocator< T, s >:

## Classes

struct | rebind
| Rebind the allocator to another type. More...

## Public Types

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.
typedef Pool< T, size > | PoolType
| The type of the memory pool we use.

## Public Member Functions

| PoolAllocator ()
| Constructor.
template<typename U, std::size_t u>
| PoolAllocator (const PoolAllocator< U, u > &)
| Copy Constructor that does not copy the memory pool.
| PoolAllocator (const PoolAllocator &)
| Copy constructor that does not copy the memory pool.
pointer | allocate (std::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 noexcept
| Not correctly implemented, yet!

## Static Public Attributes

static constexpr int | size = s * sizeof(value_type)
| The number of objects to fit into one memory chunk allocated.

## 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.

It uses a pool of memory chunks where the objects will be allocated. This means that assuming that N objects fit into memory only every N-th request for an object will result in memory allocation.

Warning
  It is not suitable for the use in standard containers as it cannot allocate arrays of arbitrary size

Template Parameters

  T | The type that will be allocated.
  s | The number of elements to fit into one memory chunk.

## Member Typedef Documentation

## const_pointer

template<class T, std::size_t s>

typedef const T* Dune::PoolAllocator< T, s >::const_pointer

The constant pointer type.

## const_reference

template<class T, std::size_t s>

typedef const T& Dune::PoolAllocator< T, s >::const_reference

The constant reference type.

## difference_type

template<class T, std::size_t s>

typedef std::ptrdiff_t Dune::PoolAllocator< T, s >::difference_type

The difference_type.

## pointer

template<class T, std::size_t s>

typedef T* Dune::PoolAllocator< T, s >::pointer

The pointer type.

## PoolType

template<class T, std::size_t s>

typedef Pool<T,size> Dune::PoolAllocator< T, s >::PoolType

The type of the memory pool we use.

## reference

template<class T, std::size_t s>

typedef T& Dune::PoolAllocator< T, s >::reference

The reference type.

## size_type

template<class T, std::size_t s>

typedef std::size_t Dune::PoolAllocator< T, s >::size_type

The size type.

## value_type

template<class T, std::size_t s>

typedef T Dune::PoolAllocator< T, s >::value_type

Type of the values we construct and allocate.

## Constructor & Destructor Documentation

## PoolAllocator() [1/2]

template<class T, std::size_t s>
template<typename U, std::size_t u>

Dune::PoolAllocator< T, s >::PoolAllocator | ( | const PoolAllocator< U, u > & |  | ) |

inline

Copy Constructor that does not copy the memory pool.

## PoolAllocator() [2/2]

template<class T, std::size_t s>

Dune::PoolAllocator< T, s >::PoolAllocator | ( | const PoolAllocator< T, s > & |  | ) |

inline

Copy constructor that does not copy the memory pool.

## Member Function Documentation

## address() [1/2]

template<class T, std::size_t s>

const_pointer Dune::PoolAllocator< T, s >::address | ( | const_reference | x | ) | const

inline

Convert a reference to a pointer.

## address() [2/2]

template<class T, std::size_t s>

pointer Dune::PoolAllocator< T, s >::address | ( | reference | x | ) | const

inline

Convert a reference to a pointer.

## max_size()

template<class T, std::size_t s>

int Dune::PoolAllocator< T, s >::max_size | ( |  | ) | const

inline noexcept

Not correctly implemented, yet!

## Member Data Documentation

## size

template<class T, std::size_t s>

int Dune::PoolAllocator< T, s >::size = s * sizeof(value_type)

static constexpr

The number of objects to fit into one memory chunk allocated.

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

- poolallocator.hh