Class fixed_map

Synopsis

#include <include/EASTL/fixed_map.h>

template <typename Key, typename T, size_t nodeCount, bool bEnableOverflow = true, typename Compare = eastl::less<Key>, typename OverflowAllocator = EASTLAllocatorType>
class fixed_map : public map<Key, T, Compare, fixed_node_allocator<sizeof(typename map<Key, T>::node_type), 
	nodeCount, EASTL_ALIGN_OF(eastl::pair<Key, T>), 0, bEnableOverflow, OverflowAllocator> >

Description

fixed_map

Implements a map with a fixed block of memory identified by the nodeCount template parameter.


Key                    The key object (key in the key/value pair).
T                      The mapped object (value in the key/value pair).
nodeCount              The max number of objects to contain.
bEnableOverflow        Whether or not we should use the global heap if our object pool is exhausted.
Compare                Compare function/object for set ordering.
OverflowAllocator              Overflow allocator, which is only used if bEnableOverflow == true. Defaults to the global heap.

Mentioned in

Inheritance

Ancestors: map

Methods

fixed_map overloadfixed_map
get_overflow_allocator overload
insertThis is an extension to the C++ standard
max_size
operator= overload
reset_lose_memory
set_overflow_allocator
swap

Source

Lines 66-114 in include/EASTL/fixed_map.h.

template <typename Key, typename T, size_t nodeCount, bool bEnableOverflow = true, typename Compare = eastl::less<Key>, typename OverflowAllocator = EASTLAllocatorType>
class fixed_map : public map<Key, T, Compare, fixed_node_allocator<sizeof(typename map<Key, T>::node_type), 
    nodeCount, EASTL_ALIGN_OF(eastl::pair<Key, T>), 0, bEnableOverflow, OverflowAllocator> >
{
public:
    typedef fixed_node_allocator<sizeof(typename map<Key, T>::node_type), nodeCount, 
                 EASTL_ALIGN_OF(eastl::pair<Key, T>), 0, bEnableOverflow, OverflowAllocator>                           fixed_allocator_type;
    typedef typename fixed_allocator_type::overflow_allocator_type                                                     overflow_allocator_type;
    typedef fixed_map<Key, T, nodeCount, bEnableOverflow, Compare, OverflowAllocator>                                  this_type;
    typedef map<Key, T, Compare, fixed_allocator_type>                                                                 base_type;
    typedef typename base_type::value_type                                                                             value_type;
    typedef typename base_type::node_type                                                                              node_type;
    typedef typename base_type::size_type                                                                              size_type;
    enum { kMaxSize = nodeCount };

    using base_type::insert;
protected:
    char mBuffer[fixed_allocator_type::kBufferSize]; // kBufferSize will take into account alignment requirements.
    using base_type::mAllocator;
public:
    fixed_map();
    explicit fixed_map(const overflow_allocator_type& overflowAllocator);
    explicit fixed_map(const Compare& compare);
    fixed_map(const this_type& x);
    fixed_map(this_type&& x);
    fixed_map(this_type&& x, const overflow_allocator_type& overflowAllocator);
    fixed_map(std::initializer_list<value_type> ilist, const overflow_allocator_type& overflowAllocator = EASTL_FIXED_MAP_DEFAULT_ALLOCATOR);
    template <typename InputIterator>
    fixed_map(InputIterator first, InputIterator last);
    this_type& operator=(const this_type& x);
    this_type& operator=(std::initializer_list<value_type> ilist);
    this_type& operator=(this_type&& x);
    void swap(this_type& x);
    void reset_lose_memory(); // This is a unilateral reset to an initially empty state. No destructors are called, no deallocation occurs.
    size_type max_size() const;
    const overflow_allocator_type& get_overflow_allocator() const EA_NOEXCEPT;
    overflow_allocator_type&       get_overflow_allocator() EA_NOEXCEPT;
    void                           set_overflow_allocator(const overflow_allocator_type& allocator);
}; // fixed_map





Add Discussion as Guest

Log in