-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitvector.h
More file actions
52 lines (42 loc) · 1.42 KB
/
Copy pathbitvector.h
File metadata and controls
52 lines (42 loc) · 1.42 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
48
49
50
51
52
#ifndef BIT_VECTOR_H__
#define BIT_VECTOR_H__
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <openssl/sha.h>
#include <openssl/md5.h>
#include <ctype.h>
using namespace std;
//A bitvector class of the size 1024 bits
//Considering a 128 byte char to represent the vector
//The MSB is the byte 127 and the LSB is the byte 0
//The index for the bit vector is 0 to 1023
class bitvector
{
public:
unsigned char byte[128];
//Initializes all the bits to 0
bitvector();
//set functions
int reset(int pos);
int set(int pos); // Sets the particular bit at pos from the MSB (Cumulative Write)
int set(string kwrd); // Sets bits corresponding to kwrd. (Cumulative Write)
// CAUTION: set(s.c_str()) calls this function.
int set(char* hex); // Sets from 256-byte char array in hex form. (Overwrite)
// Use: set((char*) s.c_str()) to call this function.
// Accumulate functions
bitvector bool_and(bitvector b);
bitvector bool_or(bitvector b);
// Compare functions
bool is_equal(bitvector b); // true if exact match.
bool is_hit(bitvector& b); // true if all bits of b match. (for AND based keywords search)
bool operator<(const bitvector &) const; // To be used as a key in STL map.
bool operator==(bitvector &right); // bloom filtering!
// bool operator!=(bitvector &right);
// Print functions
void print();
void print_hex();
void print_hex(FILE *fp);
void read_hex(FILE *fp);
};
#endif