File indexing completed on 2024-11-17 04:55:18
0001 /* 0002 SPDX-License-Identifier: MPL-2.0 0003 */ 0004 0005 /* Copyright (c) 2015 Brian R. Bondy. Distributed under the MPL2 license. 0006 * This Source Code Form is subject to the terms of the Mozilla Public 0007 * License, v. 2.0. If a copy of the MPL was not distributed with this 0008 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 0009 0010 #include <iostream> 0011 #include "BloomFilter.h" 0012 0013 using std::cout; 0014 using std::endl; 0015 0016 char separatorBuffer[32] = { 0, 0, 0, 0, 0, -128, 0, -92, 0, 0, 0, 64 }; 0017 inline bool isSeparatorChar(char c) { 0018 return !!(separatorBuffer[c / 8] & 1 << c % 8); 0019 } 0020 0021 int main(int argc, char**argv) { 0022 BloomFilter bloomFilter(8, 32); 0023 bloomFilter.setBit(static_cast<int>(':')); 0024 bloomFilter.setBit(static_cast<int>('?')); 0025 bloomFilter.setBit(static_cast<int>('/')); 0026 bloomFilter.setBit(static_cast<int>('=')); 0027 bloomFilter.setBit(static_cast<int>('^')); 0028 cout << "size: " << bloomFilter.getByteBufferSize() << endl; 0029 for (int i = 0; i < bloomFilter.getByteBufferSize(); i++) { 0030 cout << " " << static_cast<int>(bloomFilter.getBuffer()[i]); 0031 } 0032 cout << endl; 0033 0034 cout << "Separator chars: " << isSeparatorChar(':') << " " 0035 << isSeparatorChar('?') << " " << isSeparatorChar('/') << " " 0036 << isSeparatorChar('=') << isSeparatorChar('^') << endl; 0037 0038 cout << "NON Separator chars: " << isSeparatorChar('a') << " " 0039 << isSeparatorChar('!') << " " << isSeparatorChar('#') << " " 0040 << isSeparatorChar('X') << isSeparatorChar('.') 0041 << isSeparatorChar('\\') << isSeparatorChar('"') 0042 << isSeparatorChar(-128) << endl; 0043 0044 return 0; 0045 }