This is the documentation for Enlighten.
class Geo GeoFixedPoolAllocator
template<typename TStorage>
class Geo::GeoFixedPoolAllocator
A std::allocator that passes memory requests through to a single underlying GeoAllocationPage.
If you know how many nodes your list/map will use, you can create one of these to improve memory use.
Please note that there are specialized versions of GeoList (GeoFixedPoolList) and GeoMap (GeoFixedPoolMap) that use GeoFixedPoolAllocator per default.
// Setup typedef for the list type.
typedef GeoFixedPoolList<int>::Type TPoolList;
// Allocate memory for the fixed pool list.
// Make sure to use max_allocation_size since the internal data structure is larger than the payload data.
// The +1 is needed for the head of the list, where the same is required for the root of a map.
GeoAllocationPage pool;
pool.Create(TPoolList::max_allocation_size, 1000 + 1);
// Setup allocator using the already allocated memory.
GeoFixedPoolAllocator<TPoolList::value_type> allocator(&pool);
{
TPoolList list(allocator);
for(s32 i = 0; i < 1000; ++i)
{
list.insert(list.end(), 2);
}
GEO_ASSERT(pool.m_InsertionPoint == pool.kSentinel); // pool is full
} // allow list to fall out of scope
GEO_ASSERT(pool.m_InsertionPoint != pool.kSentinel); // pool is empty (or at least, not full)
Typedefs
Name | Description |
|---|---|
const TStorage * const_pointer | All functions and typedefs match those required by the C++0x standard. |
const TStorage & const_reference | All functions and typedefs match those required by the C++0x standard. |
ptrdiff_t difference_type | All functions and typedefs match those required by the C++0x standard. |
TStorage * pointer | All functions and typedefs match those required by the C++0x standard. |
TStorage & reference | All functions and typedefs match those required by the C++0x standard. |
GeoAllocationPage::TIndexer size_type | All functions and typedefs match those required by the C++0x standard. |
TStorage value_type | All functions and typedefs match those required by the C++0x standard. |
Friends
Name | Description |
|---|---|
friend class GeoFixedPoolAllocator | All functions and typedefs match those required by the C++0x standard. |
Functions
Name | Description |
|---|---|
All functions and typedefs match those required by the C++0x standard. | |
All functions and typedefs match those required by the C++0x standard. | |
allocate(size_type, GeoFixedPoolAllocator< void >::const_pointer) | All functions and typedefs match those required by the C++0x standard. |
All functions and typedefs match those required by the C++0x standard. | |
All functions and typedefs match those required by the C++0x standard. | |
All functions and typedefs match those required by the C++0x standard. | |
All functions and typedefs match those required by the C++0x standard. | |
GeoFixedPoolAllocator(const GeoFixedPoolAllocator< TOther > &) | All functions and typedefs match those required by the C++0x standard. |
All functions and typedefs match those required by the C++0x standard. |
pointer Geo::GeoFixedPoolAllocator< TStorage >::address
public: pointer address
(
reference x
) const
All functions and typedefs match those required by the C++0x standard.