yfast 0.6.1
Loading...
Searching...
No Matches
fastmap.h
1#ifndef _YFAST_INTERNAL_FASTMAP_H
2#define _YFAST_INTERNAL_FASTMAP_H
3
4#include <utility>
5
6#include <yfast/internal/avl.h>
7
8namespace yfast::internal {
9
10template <typename Key, typename Value>
11struct YFastLeaf;
12
13template <typename Key, typename Value>
14struct YFastLeaf: public AVLNodeBase<Key, YFastLeaf<Key, Value>> {
15 typedef Value DerefType;
16
17 Value value;
18
19 explicit YFastLeaf(const Key& key): AVLNodeBase<Key, YFastLeaf>(key), value() {}
20 explicit YFastLeaf(const Key& key, const Value& value): AVLNodeBase<Key, YFastLeaf>(key), value(value) {}
21 explicit YFastLeaf(const Key& key, Value&& value): AVLNodeBase<Key, YFastLeaf>(key), value(std::move(value)) {}
22
23 DerefType& deref() { return value; }
24};
25
26template <typename Key>
27struct YFastLeaf<Key, void>: public AVLNodeBase<Key, YFastLeaf<Key, void>> {
28 typedef const Key DerefType;
29
30 using AVLNodeBase<Key, YFastLeaf>::key;
31
32 explicit YFastLeaf(const Key& key): AVLNodeBase<Key, YFastLeaf>(key) {}
33
34 DerefType& deref() { return key; }
35};
36
37}
38
39#endif
Definition fastmap.h:14