-
-
Notifications
You must be signed in to change notification settings - Fork 973
Expand file tree
/
Copy pathadi_tree.h
More file actions
37 lines (22 loc) · 893 Bytes
/
Copy pathadi_tree.h
File metadata and controls
37 lines (22 loc) · 893 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
#pragma once
#include <string>
#include "sparsepp.h"
struct adi_node_t;
class adi_tree_t {
private:
spp::sparse_hash_map<uint32_t, std::string> id_keys;
adi_node_t* root = nullptr;
static void add_node(adi_node_t* node, const std::string& key, size_t key_index);
static bool rank_aggregate(adi_node_t* node, const std::string& key, size_t key_index, size_t& rank);
static adi_node_t* get_node(adi_node_t* node, const std::string& key, const size_t key_index,
std::vector<adi_node_t*>& path);
void remove_node(adi_node_t* node, const std::string& key, const size_t key_index);
public:
static constexpr size_t NOT_FOUND = INT64_MAX;
adi_tree_t();
~adi_tree_t();
void index(uint32_t id, const std::string& key);
size_t rank(uint32_t id);
void remove(uint32_t id);
const adi_node_t* get_root();
};