3#include <basis/seadNew.h>
4#include <container/seadFreeList.h>
5#include <container/seadTreeMapImpl.h>
6#include <prim/seadDelegate.h>
10template <
typename Key>
47template <
typename Key,
typename Value>
81 return this->mKey_.key;
105 fun(node->key()
, node->value()
);
123 if (!tryAllocBuffer(node_max, alignment))
125 SEAD_ASSERT_MSG(
false,
"node_max[%d] must be larger than zero", node_max);
131 if (!tryAllocBuffer(node_max, heap, alignment))
133 SEAD_ASSERT_MSG(
false,
"node_max[%d] must be larger than zero", node_max);
143 SEAD_ASSERT_MSG(
false,
"node_max[%d] must be larger than zero", node_max);
147 void* buf =
new (
nullptr, alignment) u8[node_max *
sizeof(Node)];
153 setBuffer(node_max, buf);
163 SEAD_ASSERT_MSG(
false,
"node_max[%d] must be larger than zero", node_max);
167 void* buf =
new(heap, alignment) u8[node_max *
sizeof(Node)];
173 setBuffer(node_max, buf);
194 SEAD_ASSERT_MSG(
false,
"node_max[%d] must be larger than zero", node_max);
210 bool isFull()
const {
return mSize >= mNodeMax; }
216 Value*
find(
const Key& key)
const
224 return &node->value();
229 return find(key
) !=
nullptr;
236 Value* insertedValue =
find(key
);
243 insertedValue->~Value();
244 new(insertedValue) Value();
246 return insertedValue;
253 return &node->value();
256 Value*
insert(
const Key& key,
const Value& value)
260 Value* insertedValue =
find(key
);
267 insertedValue->~Value();
268 new(insertedValue) Value(value);
270 return insertedValue;
277 return &node->value();
290 this->mRoot =
nullptr;
293 template <
typename T>
316 node->value().~Value();
327template <
typename Key,
typename Value, s32 N>
334 TreeMap<Key, Value>::setBuffer(N, mWork);
337 void allocBuffer(s32 node_max, s32 alignment = cDefaultAlignment) =
delete;
338 void allocBuffer(s32 node_max,
Heap* heap, s32 alignment = cDefaultAlignment) =
delete;
Definition seadTreeMap.h:329
void setBuffer(s32 node_max, void *buf)=delete
void allocBuffer(s32 node_max, s32 alignment=cDefaultAlignment)=delete
bool tryAllocBuffer(s32 node_max, Heap *heap, s32 alignment=cDefaultAlignment)=delete
u8 mWork[N *sizeof(typename TreeMap< Key, Value >::Node)]
Definition seadTreeMap.h:345
bool tryAllocBuffer(s32 node_max, s32 alignment=cDefaultAlignment)=delete
FixedTreeMap()
Definition seadTreeMap.h:331
void allocBuffer(s32 node_max, Heap *heap, s32 alignment=cDefaultAlignment)=delete
Definition seadFreeList.h:10
void put(void *ptr)
Definition seadFreeList.h:54
FreeList()
Definition seadFreeList.h:12
void * work() const
Definition seadFreeList.h:52
void * get()
Definition seadFreeList.h:36
void cleanup()
Definition seadFreeList.h:46
Definition seadTreeMapImpl.h:36
Definition seadTreeMapImpl.h:10
Definition seadTreeMap.h:52
Value & value()
Definition seadTreeMap.h:84
Node(const Key &akey, TreeMap *map)
Definition seadTreeMap.h:54
TreeMap * mMap
Definition seadTreeMap.h:91
void erase_() override
Definition seadTreeMap.h:71
Key & key()
Definition seadTreeMap.h:79
Node(const Key &akey, const Value &avalue, TreeMap *map)
Definition seadTreeMap.h:62
Value mValue
Definition seadTreeMap.h:90
Definition seadTreeMap.h:49
s32 mNodeMax
Definition seadTreeMap.h:324
void eraseNodeForClear_(TreeMapNode< TreeMapKeyImpl< Key > > *n)
Definition seadTreeMap.h:313
s32 maxSize() const
Definition seadTreeMap.h:214
bool tryAllocBuffer(s32 node_max, Heap *heap, s32 alignment=cDefaultAlignment)
Definition seadTreeMap.h:157
Value * insert(const Key &key, const Value &value)
Definition seadTreeMap.h:256
s32 mSize
Definition seadTreeMap.h:323
void forEach(const T &fun) const
Definition seadTreeMap.h:294
void allocBuffer(s32 node_max, s32 alignment=cDefaultAlignment)
Definition seadTreeMap.h:121
Value * insert(const Key &key)
Definition seadTreeMap.h:232
FreeList mFreeList
Definition seadTreeMap.h:322
void freeBuffer()
Definition seadTreeMap.h:177
bool isFull() const
Definition seadTreeMap.h:210
void allocBuffer(s32 node_max, Heap *heap, s32 alignment=cDefaultAlignment)
Definition seadTreeMap.h:129
void clear()
Definition seadTreeMap.h:280
bool contains(const Key &key) const
Definition seadTreeMap.h:227
bool tryAllocBuffer(s32 node_max, s32 alignment=cDefaultAlignment)
Definition seadTreeMap.h:137
bool isEmpty() const
Definition seadTreeMap.h:209
s32 size() const
Definition seadTreeMap.h:212
s32 getSize() const
Definition seadTreeMap.h:213
Value * find(const Key &key) const
Definition seadTreeMap.h:216
void eraseNode_(Node *node)
Definition seadTreeMap.h:307
void setBuffer(s32 node_max, void *buf)
Definition seadTreeMap.h:190
TreeMap()
Definition seadTreeMap.h:113
bool isBufferReady() const
Definition seadTreeMap.h:208
Definition seadAssert.h:44
#define SEAD_ASSERT(condition)
Definition seadAssert.h:24
#define SEAD_ASSERT_MSG(condition, format,...)
Definition seadAssert.h:33
Definition seadTreeMap.h:12
s32 compare(const TreeMapKeyImpl &rhs) const
Definition seadTreeMap.h:29
TreeMapKeyImpl()
Definition seadTreeMap.h:13
Key key
Definition seadTreeMap.h:44
TreeMapKeyImpl & operator=(const Key &akey)
Definition seadTreeMap.h:23
TreeMapKeyImpl(const Key &akey)
Definition seadTreeMap.h:18
Definition seadTreeMap.h:96
void call(TreeMapNode< TreeMapKeyImpl< Key > > *n)
Definition seadTreeMap.h:102
const T & fun
Definition seadTreeMap.h:109
ForEachConstContext(const T &afun)
Definition seadTreeMap.h:97