Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.

Code Block
// 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

NameDescription
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

NameDescription
friend class GeoFixedPoolAllocator

All functions and typedefs match those required by the C++0x standard.

Functions

NameDescription
address(reference)

All functions and typedefs match those required by the C++0x standard.

address(const_reference)

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.

construct(pointer, const_reference)

All functions and typedefs match those required by the C++0x standard.

deallocate(pointer, size_type)

All functions and typedefs match those required by the C++0x standard.

destroy(pointer)

All functions and typedefs match those required by the C++0x standard.

GeoFixedPoolAllocator(GeoAllocationPage *)

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.

max_size()

All functions and typedefs match those required by the C++0x standard.


Anchor
a8b499d967cd3a4e691916f64b2cf7308
a8b499d967cd3a4e691916f64b2cf7308

pointer Geo::GeoFixedPoolAllocator< TStorage >::address

...

public: pointer address
(
    reference x
) const

...

All functions and typedefs match those required by the C++0x standard.


Anchor
a4396914feaed3317a7e4a48435dbe7f1
a4396914feaed3317a7e4a48435dbe7f1

const_pointer Geo::GeoFixedPoolAllocator< TStorage >::address

...

public: const_pointer address
(
    const_reference x
) const

...

All functions and typedefs match those required by the C++0x standard.


Anchor
a9bc439375535788668a4acd4eede1420
a9bc439375535788668a4acd4eede1420

pointer Geo::GeoFixedPoolAllocator< TStorage >::allocate

...

public: pointer allocate
(
    size_type n,
    GeoFixedPoolAllocator< void >::const_pointer hint
)

...

All functions and typedefs match those required by the C++0x standard.


Anchor
aa95915a3d3ad18780d0a4179a6323be6
aa95915a3d3ad18780d0a4179a6323be6

void Geo::GeoFixedPoolAllocator< TStorage >::construct

...

public: void construct
(
    pointer p,
    const_reference val
)

...

All functions and typedefs match those required by the C++0x standard.


Anchor
aa1a7f15b517641906303105e44a39017
aa1a7f15b517641906303105e44a39017

void Geo::GeoFixedPoolAllocator< TStorage >::deallocate

...

public: void deallocate
(
    pointer p,
    size_type n
)

...

All functions and typedefs match those required by the C++0x standard.


Anchor
ad3b0f650f2909e575531d7d6d3c52aca
ad3b0f650f2909e575531d7d6d3c52aca

void Geo::GeoFixedPoolAllocator< TStorage >::destroy

...

public: void destroy
(
    pointer p
)

...

All functions and typedefs match those required by the C++0x standard.


Anchor
a4bf30e4f7c35cf64329d5507940ed037
a4bf30e4f7c35cf64329d5507940ed037

Geo::GeoFixedPoolAllocator< TStorage >::GeoFixedPoolAllocator

...

public: GeoFixedPoolAllocator
(
    GeoAllocationPage * pPool
)

...

All functions and typedefs match those required by the C++0x standard.


Anchor
ab2417b1d693e49a5f474d66fb14743fa
ab2417b1d693e49a5f474d66fb14743fa

Geo::GeoFixedPoolAllocator< TStorage >::GeoFixedPoolAllocator

...

public: GeoFixedPoolAllocator
(
    const GeoFixedPoolAllocator< TOther > & rhs
)

...

All functions and typedefs match those required by the C++0x standard.


Anchor
a381baebbd5d0165096b24a0bc7e97d5c
a381baebbd5d0165096b24a0bc7e97d5c

size_type Geo::GeoFixedPoolAllocator< TStorage >::max_size

...

public: size_type max_size() const

...

All functions and typedefs match those required by the C++0x standard.