rheolef  6.3
Classes | Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
rheolef::heap_allocator< T > Class Template Reference

heap_allocator - heap-based allocator More...

#include <heap_allocator.h>

Collaboration diagram for rheolef::heap_allocator< T >:
Collaboration graph
[legend]

Classes

struct  handler_type
struct  rebind

Public Types

typedef size_t size_type
typedef std::ptrdiff_t difference_type
typedef T * pointer
typedef const T * const_pointer
typedef T & reference
typedef const T & const_reference
typedef T value_type

Public Member Functions

 heap_allocator () throw ()
 heap_allocator (const heap_allocator &ha) throw ()
template<typename U >
 heap_allocator (const heap_allocator< U > &ha) throw ()
 ~heap_allocator () throw ()
heap_allocatoroperator= (const heap_allocator &ha)
pointer address (reference r) const
const_pointer address (const_reference c) const
size_type max_size () const
void construct (pointer p, const_reference c)
void construct (pointer p)
void destroy (pointer p)
pointer allocate (size_type n, const void *=NULL)
void deallocate (pointer p, size_type n)
const handler_typeget_handler () const

Protected Attributes

handler_typehandler

Friends

class heap_allocator

Detailed Description

template<typename T>
class rheolef::heap_allocator< T >

heap_allocator - heap-based allocator

Heap allocators are generally used when there is a lot of allocation and deallocation of small objects. For instance, this is often the case when dealing with std::list and std::map.

Heap-based allocator is conform to the STL specification of allocators. It does not "free" the memory until the heap is destroyed.

This allocator handles an a priori unlimited area of memory: a sequence of growing chunks are allocated. For a limited memory handler in the same spirit, see "stack_allocator"(9).

EXAMPLE

typedef map <size_t, double, less<size_t>, heap_allocator<pair<size_t,double> > > map_type;
map_type a;
a.insert (make_pair (0, 3.14));
a.insert (make_pair (1, 1.17));
for (map_type::iterator iter = a.begin(), last = a.end(); iter != last; iter++) {
cout << (*iter).first << " " << (*iter).second << endl;
}

Definition at line 40 of file heap_allocator.h.

Member Typedef Documentation

template<typename T>
typedef size_t rheolef::heap_allocator< T >::size_type

Definition at line 42 of file heap_allocator.h.

template<typename T>
typedef std::ptrdiff_t rheolef::heap_allocator< T >::difference_type

Definition at line 47 of file heap_allocator.h.

template<typename T>
typedef T* rheolef::heap_allocator< T >::pointer

Definition at line 48 of file heap_allocator.h.

template<typename T>
typedef const T* rheolef::heap_allocator< T >::const_pointer

Definition at line 49 of file heap_allocator.h.

template<typename T>
typedef T& rheolef::heap_allocator< T >::reference

Definition at line 50 of file heap_allocator.h.

template<typename T>
typedef const T& rheolef::heap_allocator< T >::const_reference

Definition at line 51 of file heap_allocator.h.

template<typename T>
typedef T rheolef::heap_allocator< T >::value_type

Definition at line 52 of file heap_allocator.h.

Constructor & Destructor Documentation

template<typename T>
rheolef::heap_allocator< T >::heap_allocator ( ) throw ()
inline

Definition at line 55 of file heap_allocator.h.

template<typename T>
rheolef::heap_allocator< T >::heap_allocator ( const heap_allocator< T > &  ha) throw ()
inline

Definition at line 59 of file heap_allocator.h.

template<typename T>
template<typename U >
rheolef::heap_allocator< T >::heap_allocator ( const heap_allocator< U > &  ha) throw ()
inline

Definition at line 65 of file heap_allocator.h.

template<typename T>
rheolef::heap_allocator< T >::~heap_allocator ( ) throw ()
inline

Definition at line 70 of file heap_allocator.h.

Member Function Documentation

template<typename T>
heap_allocator& rheolef::heap_allocator< T >::operator= ( const heap_allocator< T > &  ha)
inline

Definition at line 81 of file heap_allocator.h.

template<typename T>
pointer rheolef::heap_allocator< T >::address ( reference  r) const
inline

Definition at line 89 of file heap_allocator.h.

template<typename T>
const_pointer rheolef::heap_allocator< T >::address ( const_reference  c) const
inline

Definition at line 90 of file heap_allocator.h.

template<typename T>
size_type rheolef::heap_allocator< T >::max_size ( ) const
inline

Definition at line 91 of file heap_allocator.h.

template<typename T>
void rheolef::heap_allocator< T >::construct ( pointer  p,
const_reference  c 
)
inline

Definition at line 95 of file heap_allocator.h.

template<typename T>
void rheolef::heap_allocator< T >::construct ( pointer  p)
inline

Definition at line 99 of file heap_allocator.h.

template<typename T>
void rheolef::heap_allocator< T >::destroy ( pointer  p)
inline

Definition at line 101 of file heap_allocator.h.

template<typename T>
pointer rheolef::heap_allocator< T >::allocate ( size_type  n,
const void *  = NULL 
)
inline

Definition at line 107 of file heap_allocator.h.

template<typename T>
void rheolef::heap_allocator< T >::deallocate ( pointer  p,
size_type  n 
)
inline

Definition at line 111 of file heap_allocator.h.

template<typename T>
const handler_type* rheolef::heap_allocator< T >::get_handler ( ) const
inline

Definition at line 114 of file heap_allocator.h.

Friends And Related Function Documentation

template<typename T>
friend class heap_allocator
friend

Definition at line 121 of file heap_allocator.h.

Member Data Documentation

template<typename T>
handler_type* rheolef::heap_allocator< T >::handler
protected

Definition at line 120 of file heap_allocator.h.


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