ezEngine  Release 25.03
ezMap< KeyType, ValueType, Comparer, AllocatorWrapper > Class Template Reference

#include <Map.h>

Inheritance diagram for ezMap< KeyType, ValueType, Comparer, AllocatorWrapper >:

Public Member Functions

 ezMap (ezAllocator *pAllocator)
 
 ezMap (const Comparer &comparer, ezAllocator *pAllocator)
 
 ezMap (const ezMap< KeyType, ValueType, Comparer, AllocatorWrapper > &other)
 
 ezMap (const ezMapBase< KeyType, ValueType, Comparer > &other)
 
void operator= (const ezMap< KeyType, ValueType, Comparer, AllocatorWrapper > &rhs)
 
void operator= (const ezMapBase< KeyType, ValueType, Comparer > &rhs)
 
- Public Member Functions inherited from ezMapBase< KeyType, ValueType, ezCompareHelper< KeyType > >
bool IsEmpty () const
 Returns whether there are no elements in the map. O(1) operation.
 
ezUInt32 GetCount () const
 Returns the number of elements currently stored in the map. O(1) operation.
 
void Clear ()
 Destroys all elements in the map and resets its size to zero.
 
Iterator GetIterator ()
 Returns an Iterator to the very first element.
 
ConstIterator GetIterator () const
 Returns a constant Iterator to the very first element.
 
ReverseIterator GetReverseIterator ()
 Returns a ReverseIterator to the very last element.
 
ConstReverseIterator GetReverseIterator () const
 Returns a constant ReverseIterator to the very last element.
 
Iterator Insert (CompatibleKeyType &&key, CompatibleValueType &&value)
 Inserts the key/value pair into the tree and returns an Iterator to it. O(log n) operation.
 
bool Remove (const CompatibleKeyType &key)
 Erases the key/value pair with the given key, if it exists. O(log n) operation.
 
Iterator Remove (const Iterator &pos)
 Erases the key/value pair at the given Iterator. O(log n) operation. Returns an iterator to the element after the given iterator.
 
Iterator FindOrAdd (CompatibleKeyType &&key, bool *out_pExisted=nullptr)
 Searches for the given key and returns an iterator to it. If it did not exist yet, it is default-created. bExisted is set to true, if the key was found, false if it needed to be created.
 
ValueType & operator[] (const CompatibleKeyType &key)
 Allows read/write access to the value stored under the given key. If there is no such key, a new element is default-constructed.
 
bool TryGetValue (const CompatibleKeyType &key, ValueType &out_value) const
 Returns whether an entry with the given key was found and if found writes out the corresponding value to out_value.
 
bool TryGetValue (const CompatibleKeyType &key, const ValueType *&out_pValue) const
 Returns whether an entry with the given key was found and if found writes out the pointer to the corresponding value to out_pValue.
 
bool TryGetValue (const CompatibleKeyType &key, ValueType *&out_pValue) const
 Returns whether an entry with the given key was found and if found writes out the pointer to the corresponding value to out_pValue.
 
EZ_ALWAYS_INLINE bool TryGetValue (const CompatibleKeyType &key, ValueType &out_value) const
 
EZ_ALWAYS_INLINE bool TryGetValue (const CompatibleKeyType &key, const ValueType *&out_pValue) const
 
EZ_ALWAYS_INLINE bool TryGetValue (const CompatibleKeyType &key, ValueType *&out_pValue) const
 
const ValueType * GetValue (const CompatibleKeyType &key) const
 Returns a pointer to the value of the entry with the given key if found, otherwise returns nullptr.
 
ValueType * GetValue (const CompatibleKeyType &key)
 Returns a pointer to the value of the entry with the given key if found, otherwise returns nullptr.
 
const EZ_ALWAYS_INLINE ValueType * GetValue (const CompatibleKeyType &key) const
 
EZ_ALWAYS_INLINE ValueType * GetValue (const CompatibleKeyType &key)
 
const ValueType & GetValueOrDefault (const CompatibleKeyType &key, const ValueType &defaultValue) const
 Either returns the value of the entry with the given key, if found, or the provided default value.
 
const EZ_ALWAYS_INLINE ValueType & GetValueOrDefault (const CompatibleKeyType &key, const ValueType &defaultValue) const
 
Iterator Find (const CompatibleKeyType &key)
 Searches for key, returns an Iterator to it or an invalid iterator, if no such key is found. O(log n) operation.
 
ConstIterator Find (const CompatibleKeyType &key) const
 Searches for key, returns an Iterator to it or an invalid iterator, if no such key is found. O(log n) operation.
 
EZ_ALWAYS_INLINE ezMapBase< KeyType, ValueType, ezCompareHelper< KeyType > >::Iterator Find (const CompatibleKeyType &key)
 
EZ_ALWAYS_INLINE ezMapBase< KeyType, ValueType, ezCompareHelper< KeyType > >::ConstIterator Find (const CompatibleKeyType &key) const
 
Iterator LowerBound (const CompatibleKeyType &key)
 Returns an Iterator to the element with a key equal or larger than the given key. Returns an invalid iterator, if there is no such element.
 
ConstIterator LowerBound (const CompatibleKeyType &key) const
 Returns an Iterator to the element with a key equal or larger than the given key. Returns an invalid iterator, if there is no such element.
 
EZ_ALWAYS_INLINE ezMapBase< KeyType, ValueType, ezCompareHelper< KeyType > >::Iterator LowerBound (const CompatibleKeyType &key)
 
EZ_ALWAYS_INLINE ezMapBase< KeyType, ValueType, ezCompareHelper< KeyType > >::ConstIterator LowerBound (const CompatibleKeyType &key) const
 
Iterator UpperBound (const CompatibleKeyType &key)
 Returns an Iterator to the element with a key that is LARGER than the given key. Returns an invalid iterator, if there is no such element.
 
ConstIterator UpperBound (const CompatibleKeyType &key) const
 Returns an Iterator to the element with a key that is LARGER than the given key. Returns an invalid iterator, if there is no such element.
 
EZ_ALWAYS_INLINE ezMapBase< KeyType, ValueType, ezCompareHelper< KeyType > >::Iterator UpperBound (const CompatibleKeyType &key)
 
EZ_ALWAYS_INLINE ezMapBase< KeyType, ValueType, ezCompareHelper< KeyType > >::ConstIterator UpperBound (const CompatibleKeyType &key) const
 
bool Contains (const CompatibleKeyType &key) const
 Checks whether the given key is in the container.
 
EZ_ALWAYS_INLINE bool Contains (const CompatibleKeyType &key) const
 
ezAllocatorGetAllocator () const
 Returns the allocator that is used by this instance.
 
bool operator== (const ezMapBase< KeyType, ValueType, ezCompareHelper< KeyType > > &rhs) const
 Comparison operator.
 
 EZ_ADD_DEFAULT_OPERATOR_NOTEQUAL (const ezMapBase< KeyType, ValueType, ezCompareHelper< KeyType > > &)
 
ezUInt64 GetHeapMemoryUsage () const
 Returns the amount of bytes that are currently allocated on the heap.
 
void Swap (ezMapBase< KeyType, ValueType, ezCompareHelper< KeyType > > &other)
 Swaps this map with the other one.
 

Additional Inherited Members

- Public Types inherited from ezMapBase< KeyType, ValueType, ezCompareHelper< KeyType > >
using ConstIterator = ezMapBaseConstIteratorBase< KeyType, ValueType, ezCompareHelper< KeyType >, false >
 
using ConstReverseIterator = ezMapBaseConstIteratorBase< KeyType, ValueType, ezCompareHelper< KeyType >, true >
 
using Iterator = ezMapBaseIteratorBase< KeyType, ValueType, ezCompareHelper< KeyType >, false >
 
using ReverseIterator = ezMapBaseIteratorBase< KeyType, ValueType, ezCompareHelper< KeyType >, true >
 
- Protected Member Functions inherited from ezMapBase< KeyType, ValueType, ezCompareHelper< KeyType > >
 ezMapBase (const ezCompareHelper< KeyType > &comparer, ezAllocator *pAllocator)
 Initializes the map to be empty.
 
 ezMapBase (const ezMapBase< KeyType, ValueType, ezCompareHelper< KeyType > > &cc, ezAllocator *pAllocator)
 Copies all key/value pairs from the given map into this one.
 
 ~ezMapBase ()
 Destroys all elements from the map.
 
void operator= (const ezMapBase< KeyType, ValueType, ezCompareHelper< KeyType > > &rhs)
 Copies all key/value pairs from the given map into this one.
 

Detailed Description

template<typename KeyType, typename ValueType, typename Comparer = ezCompareHelper<KeyType>, typename AllocatorWrapper = ezDefaultAllocatorWrapper>
class ezMap< KeyType, ValueType, Comparer, AllocatorWrapper >

See also
ezMapBase

The documentation for this class was generated from the following files: