|
7 | 7 | #include <stdlib.h> |
8 | 8 | #include "ewah.h" |
9 | 9 |
|
| 10 | +void easydemo() { |
| 11 | + typedef EWAHBoolArray<uint32_t> bitmap; |
| 12 | + bitmap bitset1 = |
| 13 | + bitmap::bitmapOf(9, 1, 2, 1000, 1001, 1002, 1003, 1007, 1009, 100000); |
| 14 | + std::cout << "first bitset : " << bitset1 << std::endl; |
| 15 | + bitmap bitset2 = bitmap::bitmapOf(5, 1, 3, 1000, 1007, 100000); |
| 16 | + std::cout << "second bitset : " << bitset2 << std::endl; |
| 17 | + bitmap bitset3 = bitmap::bitmapOf(3, 10, 11, 12); |
| 18 | + std::cout << "third bitset : " << bitset3 << std::endl; |
| 19 | + bitmap orbitset = bitset1 | bitset2; |
| 20 | + bitmap andbitset = bitset1 & bitset2; |
| 21 | + bitmap xorbitset = bitset1 ^ bitset2; |
| 22 | + bitmap andnotbitset = bitset1 - bitset2; |
| 23 | + |
| 24 | + std::cout << "logical and: " << andbitset << std::endl; |
| 25 | + std::cout << "memory usage of compressed bitset = " << andbitset.sizeInBytes() |
| 26 | + << " bytes" << std::endl; |
| 27 | + // we will display the and |
| 28 | + std::cout << "logical or: " << orbitset << std::endl; |
| 29 | + std::cout << "memory usage of compressed bitset = " << orbitset.sizeInBytes() |
| 30 | + << " bytes" << std::endl; |
| 31 | + // we will display the xor |
| 32 | + std::cout << "logical xor: " << xorbitset << std::endl; |
| 33 | + std::cout << "memory usage of compressed bitset = " << xorbitset.sizeInBytes() |
| 34 | + << " bytes" << std::endl; |
| 35 | + std::cout << "union of all three bitsets = " << (orbitset | bitset3) |
| 36 | + << std::endl; |
| 37 | + const bitmap *mybitmaps[] = {&bitset1, &bitset2, &bitset3}; |
| 38 | + std::cout << "fast union of all three bitsets = " |
| 39 | + << fast_logicalor(3, mybitmaps) << std::endl; |
| 40 | + |
| 41 | + std::cout << std::endl; |
| 42 | +} |
| 43 | + |
10 | 44 | template <class bitmap> void demo() { |
11 | 45 | bitmap bitset1 = |
12 | 46 | bitmap::bitmapOf(9, 1, 2, 1000, 1001, 1002, 1003, 1007, 1009, 100000); |
@@ -109,6 +143,8 @@ int main(void) { |
109 | 143 | std::cout << std::endl; |
110 | 144 | std::cout << "====compressed example====" << std::endl; |
111 | 145 | std::cout << std::endl; |
| 146 | + easydemo(); |
| 147 | + |
112 | 148 | demo<EWAHBoolArray<uint32_t>>(); |
113 | 149 | demoSerialization<EWAHBoolArray<uint32_t>>(); |
114 | 150 | std::cout << "==== benchmark intersecs === " << std::endl; |
|
0 commit comments