forked from bbondy/bloom-filter-cpp
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
41 lines (34 loc) · 1.48 KB
/
main.cpp
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
/* Copyright (c) 2015 Brian R. Bondy. Distributed under the MPL2 license.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <iostream>
#include "BloomFilter.h"
using std::cout;
using std::endl;
char separatorBuffer[32] = { 0, 0, 0, 0, 0, -128, 0, -92, 0, 0, 0, 64 };
inline bool isSeparatorChar(char c) {
return !!(separatorBuffer[c / 8] & 1 << c % 8);
}
int main(int argc, char**argv) {
BloomFilter bloomFilter(8, 32);
bloomFilter.setBit(static_cast<int>(':'));
bloomFilter.setBit(static_cast<int>('?'));
bloomFilter.setBit(static_cast<int>('/'));
bloomFilter.setBit(static_cast<int>('='));
bloomFilter.setBit(static_cast<int>('^'));
cout << "size: " << bloomFilter.getByteBufferSize() << endl;
for (int i = 0; i < bloomFilter.getByteBufferSize(); i++) {
cout << " " << static_cast<int>(bloomFilter.getBuffer()[i]);
}
cout << endl;
cout << "Separator chars: " << isSeparatorChar(':') << " "
<< isSeparatorChar('?') << " " << isSeparatorChar('/') << " "
<< isSeparatorChar('=') << isSeparatorChar('^') << endl;
cout << "NON Separator chars: " << isSeparatorChar('a') << " "
<< isSeparatorChar('!') << " " << isSeparatorChar('#') << " "
<< isSeparatorChar('X') << isSeparatorChar('.')
<< isSeparatorChar('\\') << isSeparatorChar('"')
<< isSeparatorChar(-128) << endl;
return 0;
}