-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflatinvmap.h
89 lines (62 loc) · 2.06 KB
/
flatinvmap.h
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef __INVFLATMAP_H_INCLUDED__
#define __INVFLATMAP_H_INCLUDED__
#include <utility>
#include "bloom_filter.h"
using ElemT = std::pair<int, int>;
class FlatInvMap {
public:
FlatInvMap() = default;
FlatInvMap(const int arr[], int size);
virtual ~FlatInvMap() = default;
FlatInvMap(const FlatInvMap&) = delete;
FlatInvMap& operator=(const FlatInvMap&) = delete;
FlatInvMap(FlatInvMap&&) = default;
FlatInvMap& operator=(FlatInvMap&&) = default;
ElemT* cend() const;
ElemT* find(int) const;
protected:
ElemT* find_in_range(int, ElemT*, ElemT*) const;
int size = 0;
ElemT* invarr = nullptr;
};
class FlatBFInvMap: public FlatInvMap {
public:
FlatBFInvMap(const int arr[], int size);
virtual ~FlatBFInvMap() = default;
FlatBFInvMap(const FlatBFInvMap&) = delete;
FlatBFInvMap& operator=(const FlatBFInvMap&) = delete;
FlatBFInvMap(FlatBFInvMap&&) = default;
FlatBFInvMap& operator=(FlatBFInvMap&&) = default;
ElemT* find(int) const;
private:
BloomFilter bf;
};
class FlatBSInvMap: public FlatInvMap {
public:
FlatBSInvMap() = default;
FlatBSInvMap(const int arr[], int size);
virtual ~FlatBSInvMap() = default;
FlatBSInvMap(const FlatBSInvMap&) = delete;
FlatBSInvMap& operator=(const FlatBSInvMap&) = delete;
FlatBSInvMap(FlatBSInvMap&&) = default;
FlatBSInvMap& operator=(FlatBSInvMap&&) = default;
ElemT* find(int) const;
private:
std::vector<bool> table;
};
class FlatSummarizerInvMap: public FlatInvMap {
public:
FlatSummarizerInvMap() = default;
FlatSummarizerInvMap(const int arr[], int size);
virtual ~FlatSummarizerInvMap() = default;
FlatSummarizerInvMap(const FlatSummarizerInvMap&) = delete;
FlatSummarizerInvMap& operator=(const FlatSummarizerInvMap&) = delete;
FlatSummarizerInvMap(FlatSummarizerInvMap&&) = default;
FlatSummarizerInvMap& operator=(FlatSummarizerInvMap&&) = default;
ElemT* find(int) const;
private:
int step = 0;
int summary_size = 0;
int* summary = nullptr;
};
#endif // __INVFLATMAP_H_INCLUDED__