The fixed width storage policy implements a bit vector where each cell represents a counter having a fixed number of bits. More...
#include <counter_vector.h>
Public Member Functions  
counter_vector (size_t cells, size_t width)  
Construct a counter vector of size \(O(mw)\) where *m is the number of cells and *w the number of bits per cell. More...  
bool  increment (size_t cell, size_t value=1) 
Increments a cell counter by a given value. More...  
bool  decrement (size_t cell, size_t value=1) 
Decrements a cell counter. More...  
size_t  count (size_t cell) const 
Retrieves the counter of a cell. More...  
void  set (size_t cell, size_t value) 
Sets a cell to a given value. More...  
void  clear () 
Sets all counter values to 0.  
size_t  size () const 
Retrieves the number of cells. More...  
size_t  max () const 
Retrieves the maximum possible counter value. More...  
size_t  width () const 
Retrieves the counter width. More...  
Private Attributes  
bitvector  bits_ 
size_t  width_ 
Friends  
std::string  to_string (counter_vector const &, bool, size_t) 
Generates a string representation of a counter vector. More...  
The fixed width storage policy implements a bit vector where each cell represents a counter having a fixed number of bits.
Definition at line 12 of file counter_vector.h.
bf::counter_vector::counter_vector  (  size_t  cells, 
size_t  width  
) 
Construct a counter vector of size \(O(mw)\) where *m is the number of cells and *w the number of bits per cell.
cells  The number of cells. 
width  The number of bits per cell. 
cells > 0 && width > 0
Definition at line 7 of file counter_vector.cc.
size_t bf::counter_vector::count  (  size_t  cell  )  const 
Retrieves the counter of a cell.
cell  The cell index. 
Definition at line 62 of file counter_vector.cc.
References size().
Referenced by bf::counting_bloom_filter::count(), bf::counting_bloom_filter::find_minima(), bf::counting_bloom_filter::find_minimum(), and bf::counting_bloom_filter::lookup().
bool bf::counter_vector::decrement  (  size_t  cell, 
size_t  value = 1 

) 
Decrements a cell counter.
cell  The cell index. 
true
if decrementing succeeded, false
if all bits in the cell were already 0. Definition at line 46 of file counter_vector.cc.
References size().
Referenced by bf::stable_bloom_filter::add(), and bf::counting_bloom_filter::decrement().
bool bf::counter_vector::increment  (  size_t  cell, 
size_t  value = 1 

) 
Increments a cell counter by a given value.
If the value is larger than or equal to max(), all bits are set to 1.
cell  The cell index. 
value  The value that is added to the current cell value. 
true
if the increment succeeded, false
if all bits in the cell were already 1. Definition at line 14 of file counter_vector.cc.
Referenced by bf::counting_bloom_filter::increment().
size_t bf::counter_vector::max  (  )  const 
Retrieves the maximum possible counter value.
Definition at line 93 of file counter_vector.cc.
References width().
Referenced by bf::stable_bloom_filter::add(), bf::counting_bloom_filter::find_minima(), bf::counting_bloom_filter::find_minimum(), increment(), bf::counting_bloom_filter::lookup(), and set().
void bf::counter_vector::set  (  size_t  cell, 
size_t  value  
) 
Sets a cell to a given value.
cell  The cell whose value changes. 
value  The new value of the cell. 
Definition at line 73 of file counter_vector.cc.
size_t bf::counter_vector::size  (  )  const 
Retrieves the number of cells.
Definition at line 88 of file counter_vector.cc.
References bf::bitvector::size().
Referenced by count(), decrement(), bf::counting_bloom_filter::find_indices(), increment(), and set().
size_t bf::counter_vector::width  (  )  const 
Retrieves the counter width.
Definition at line 99 of file counter_vector.cc.
Referenced by max().

friend 
Generates a string representation of a counter vector.
The arguments have the same meaning as in bf::bitvector.
Definition at line 104 of file counter_vector.cc.