Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
Loading...
Searching...
No Matches
data_structures::Bitset Class Reference

Simple bitset implementation for bloom filter. More...

Collaboration diagram for data_structures::Bitset:
[legend]

Public Member Functions

 Bitset (std::size_t)
 BitSet class constructor.
 
std::size_t size ()
 Utility function to return the size of the inner array.
 
void add (std::size_t)
 Turn bit on position x to 1s.
 
bool contains (std::size_t)
 Doest bitset contains element x.
 

Private Attributes

std::vector< std::size_tdata
 short info of this variable
 

Static Private Attributes

static const std::size_t blockSize
 

Detailed Description

Simple bitset implementation for bloom filter.

Constructor & Destructor Documentation

◆ Bitset()

data_structures::Bitset::Bitset ( std::size_t initSize)
explicit

BitSet class constructor.

Parameters
initSizeamount of blocks, each contain sizeof(std::size_t) bits
63: data(initSize) {}
std::vector< std::size_t > data
short info of this variable
Definition bloom_filter.cpp:42

Member Function Documentation

◆ add()

void data_structures::Bitset::add ( std::size_t x)

Turn bit on position x to 1s.

Parameters
xposition to turn bit on
Returns
void
71 {
72 std::size_t blockIndex = x / blockSize;
73 if (blockIndex >= data.size()) {
74 data.resize(blockIndex + 1);
75 }
76 data[blockIndex] |= 1 << (x % blockSize);
77}
static const std::size_t blockSize
Definition bloom_filter.cpp:43
T resize(T... args)
T size(T... args)
Here is the call graph for this function:

◆ contains()

bool data_structures::Bitset::contains ( std::size_t x)

Doest bitset contains element x.

Parameters
xposition in bitset to check
Returns
true if bit position x is 1
false if bit position x is 0
86 {
87 std::size_t blockIndex = x / blockSize;
88 if (blockIndex >= data.size()) {
89 return false;
90 }
91 return data[blockIndex] & (1 << (x % blockSize));
92}
Here is the call graph for this function:

◆ size()

std::size_t data_structures::Bitset::size ( )

Utility function to return the size of the inner array.

Returns
the size of inner array
57{ return data.size(); }
Here is the call graph for this function:

Member Data Documentation

◆ blockSize

const std::size_t data_structures::Bitset::blockSize
staticprivate
Initial value:
=
sizeof(std::size_t)

size of integer type, that we are using in our bitset


The documentation for this class was generated from the following file: