-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (40 loc) · 1.15 KB
/
main.cpp
File metadata and controls
47 lines (40 loc) · 1.15 KB
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
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include "./CuckooFilter.h"
using namespace std;
#define TABLE_SIZE 2
int main() {
// Create cuckoo filter with 2 buckets.
CuckooFilter filter(TABLE_SIZE);
vector<string> elements = {"chepson", "gerald", "TheProcess", "brandon"};
vector<string> mixedElements = {"chepson", "gerald", "TheProcess", "brandon", "placali", "Koded"};
// INSERTION
for (auto elt : elements) {
if (filter.Insert(elt)) {
cout << elt + " inserted to filter. " << endl;
}
else {
cout << elt + " cannot be inserted since filter is full. RE-HASH all elements" << endl;
}
}
cout << endl;
// SEARCHING.
for (auto elt : mixedElements) {
if (filter.Lookup(elt)) {
cout << elt + " might be in filter. " << endl;
}
else {
cout << elt + " is definitely not in filter. " << endl;
}
}
cout << endl;
// DELETION
for (auto elt : elements) {
if (filter.Delete(elt)) {
cout << elt + " removed from filter. " << endl;
}
}
return 1;
}