-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbptree_set.h
More file actions
53 lines (44 loc) · 1003 Bytes
/
bptree_set.h
File metadata and controls
53 lines (44 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Author: Abby Cin
* Mail: abbytsing@gmail.com
* Create Time: 2024-06-22 12:37:23
*/
#ifndef BPTREE_SET_1719031043_H_
#define BPTREE_SET_1719031043_H_
#include "bptree.h"
namespace nm
{
namespace detail
{
template<typename T>
struct BpTreeSetPolicy {
static_assert(!std::is_reference_v<T>,
"forbid reference as key");
using key_type = std::remove_cvref_t<T>;
using value_type = key_type;
static const key_type &key(const value_type &v)
{
return v;
}
};
}
template<typename Key, int M = 3>
class BpTreeSet : public BpTree<detail::BpTreeSetPolicy<Key>, M> {
using Base = BpTree<detail::BpTreeSetPolicy<Key>, M>;
public:
using Base::Base;
using Base::put;
using Base::get;
using Base::del;
using Base::range;
using Base::clear;
using iter = typename Base::iter;
BpTreeSet(std::initializer_list<typename Base::val_t> il) : Base {}
{
for (auto &&x : il)
put(x);
}
};
}
#endif // BPTREE_SET_1719031043_H_