8template <
class KeyType,
class ValueType,
class Comparator = TComparator<KeyType>>
19 : m_RedBlackTree( a_pAllocator )
30 m_RedBlackTree.DeleteAll();
35 return m_RedBlackTree.Size();
38 template <
class... Args>
39 ValueType*
Emplace(
const KeyType& key, Args&&... args )
41 Pair pair{ key, ValueType( std::forward<Args>( args )... ) };
42 Iterator result = m_RedBlackTree.Insert( std::move( pair ) );
43 return &result.
GetValue()->GetSecond();
46 ValueType*
Insert(
const KeyType& key,
const ValueType& value )
48 Pair pair{ key, value };
49 Iterator result = m_RedBlackTree.Insert( std::move( pair ) );
50 return &result.
GetValue()->GetSecond();
53 ValueType*
Insert(
const KeyType& key, ValueType&& value )
55 Pair pair{ key, std::move( value ) };
56 Iterator result = m_RedBlackTree.Insert( std::move( pair ) );
57 return &result.
GetValue()->GetSecond();
62 Iterator result = m_RedBlackTree.Find( { key } );
65 m_RedBlackTree.Delete( result.
GetNode() );
71 m_RedBlackTree.Delete( it.
GetNode() );
76 for (
auto it =
Begin(); it !=
End(); it++ )
78 if ( it.GetValue()->GetSecond() == value )
89 return m_RedBlackTree.Find( { key } );
94 return m_RedBlackTree.FindNext( a_oIterator.
GetNode(), { a_rKey } );
99 return a_oIterator !=
End();
104 return m_RedBlackTree.Begin();
109 return m_RedBlackTree.End();
114 return m_RedBlackTree.Begin();
119 return m_RedBlackTree.End();
129 return m_RedBlackTree.Find( { key } );
134 return m_RedBlackTree.GetAllocator();
#define TOSHI_NAMESPACE_START
#define TOSHI_NAMESPACE_END
TFORCEINLINE T2Allocator * GetGlobalAllocator()
Red-black tree implementation for the Toshi engine.
T2RedBlackTree< Pair >::Iterator Iterator
T2Map(T2Allocator *a_pAllocator=GetGlobalAllocator())
TBOOL IsValid(Iterator a_oIterator) const
T2RedBlackTree< Pair >::CIterator CIterator
void Remove(const KeyType &key)
Iterator Find(const KeyType &key)
Iterator FindNext(Iterator a_oIterator, const KeyType &a_rKey)
Iterator operator[](const KeyType &key)
ValueType * Emplace(const KeyType &key, Args &&... args)
T2Allocator * GetAllocator() const
Iterator FindByValue(const ValueType &value)
T2RedBlackTree< Pair >::Node Node
const CIterator End() const
void Remove(Iterator &it)
ValueType * Insert(const KeyType &key, ValueType &&value)
ValueType * Insert(const KeyType &key, const ValueType &value)
T2Pair< KeyType, ValueType, Comparator > Pair
const CIterator Begin() const
T2RedBlackTreeNode< T > Node
TFORCEINLINE Node * GetNode()
TFORCEINLINE T * GetValue()