NLMISC::CSTLBlockAllocator< T > Class Template Reference

#include <stl_block_allocator.h>


Detailed Description

template<class T>
class NLMISC::CSTLBlockAllocator< T >

This class is a STL block allocator which use CBlockMemory. see CBlockMemory for description of block memory management/advantages.

This class works with STLPort. It implements __stl_alloc_rebind() (not C++ standard??) to work properly with list<>/set<> etc... node allocations.

NB: if used with a vector<> or a deque<> (ie if allocate(..,n) is called with n>1), it's still work, but it's use malloc()/free() instead, so it is fully unusefull in this case :)

CSTLBlockAllocator use a pointer on a CBlockMemory, so multiple containers can share the same blockMemory, for maximum space/speed efficiency.

Because of CBlockMemory allocation scheme, only same containers of same types can share the same CBlockMemory instance (eg: "list<uint, &myBlockMemory>; vector<uint, &myBlockMemory>;" is invalid and will assert when allocations will occur).

To construct a container which use this allocator, do like this: list<uint, CSTLBlockAllocator<uint>> myList( ptrOnBlockMemory );

But see CSTLBlockList for easier list instanciation, because using it, you'll do like this: CSTLBlockList<uint> myList(ptrOnBlockMemory);

Note: CSTLBlockAllocator take only 4 bytes in memory (a ptr on a CBlockMemory)

Author:
Lionel Berenguier

Nevrax France

Date:
2001
Todo:
yoyo: make it work under linux. For now, use std allocator instead...

Definition at line 192 of file stl_block_allocator.h.

Public Member Functions

 CSTLBlockAllocator (const CSTLBlockAllocator< T > &other)
 copy ctor

 CSTLBlockAllocator (CBlockMemory< T, false > *bm)
 Constructor. Must gives a blockMemory to ctor. NB: must gives a CBlockMemory<T, false> !!!

 ~CSTLBlockAllocator ()
 dtor


Constructor & Destructor Documentation

template<class T>
NLMISC::CSTLBlockAllocator< T >::CSTLBlockAllocator CBlockMemory< T, false > *  bm  )  [inline]
 

Constructor. Must gives a blockMemory to ctor. NB: must gives a CBlockMemory<T, false> !!!

Definition at line 197 of file stl_block_allocator.h.

00198         {
00199         }

template<class T>
NLMISC::CSTLBlockAllocator< T >::CSTLBlockAllocator const CSTLBlockAllocator< T > &  other  )  [inline]
 

copy ctor

Definition at line 201 of file stl_block_allocator.h.

00201                                                                : std::allocator<T>(other)
00202         {
00203         }

template<class T>
NLMISC::CSTLBlockAllocator< T >::~CSTLBlockAllocator  )  [inline]
 

dtor

Definition at line 205 of file stl_block_allocator.h.

00206         {
00207         }


The documentation for this class was generated from the following file:
Generated on Tue Mar 16 13:35:00 2004 for NeL by doxygen 1.3.6