#include <stl_block_allocator.h>
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)
Nevrax France
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. 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 }
|
|
||||||||||
|
copy ctor
Definition at line 201 of file stl_block_allocator.h.
00201 : std::allocator<T>(other)
00202 {
00203 }
|
|
|||||||||
|
dtor
Definition at line 205 of file stl_block_allocator.h.
00206 {
00207 }
|
1.3.6