libtasks Documentation  1.6
tasks::tools::bitset Class Reference

A thread safe lock free bitset. More...

#include <bitset.h>

Collaboration diagram for tasks::tools::bitset:

Public Types

using data_type = std::atomic< bool >
 
using int_type = std::vector< data_type >::size_type
 

Public Member Functions

 bitset (int_type bits=8)
 
int_type bits () const
 
size_t buckets () const
 
void toggle (int_type p)
 Toggle a bit. More...
 
void set (int_type p)
 Set a bit. More...
 
void unset (int_type p)
 Unset a bit. More...
 
bool test (int_type p) const
 Test if a bit is set. More...
 
bool any (int_type &offset) const
 
bool first (int_type &idx) const
 
bool next (int_type &idx, int_type start=0) const
 
std::string to_string ()
 Return a string representation. More...
 

Private Attributes

std::vector< data_typem_bitset
 
int_type m_bits
 

Detailed Description

A thread safe lock free bitset.

Definition at line 20 of file bitset.h.

Member Typedef Documentation

using tasks::tools::bitset::data_type = std::atomic<bool>

Definition at line 22 of file bitset.h.

using tasks::tools::bitset::int_type = std::vector<data_type>::size_type

Definition at line 23 of file bitset.h.

Constructor & Destructor Documentation

tasks::tools::bitset::bitset ( int_type  bits = 8)
inline

Constructor

Parameters
bitsThe number if bits the bitset should keep.

Definition at line 28 of file bitset.h.

Member Function Documentation

bool tasks::tools::bitset::any ( int_type offset) const
inline
Returns
True if at least one bit is set. The bit offset is set to the offset parameter.

Definition at line 63 of file bitset.h.

Here is the caller graph for this function:

int_type tasks::tools::bitset::bits ( ) const
inline
Returns
The number of bits the bitset keeps.

Definition at line 33 of file bitset.h.

Here is the caller graph for this function:

size_t tasks::tools::bitset::buckets ( ) const
inline

Returns
The number of bits the bitset keeps.

Definition at line 36 of file bitset.h.

Here is the caller graph for this function:

bool tasks::tools::bitset::first ( int_type idx) const
inline

Definition at line 75 of file bitset.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bool tasks::tools::bitset::next ( int_type idx,
int_type  start = 0 
) const
inline

Find a bit that is set. The full bitset will be searched as worst case.

Parameters
idxThe index of the first bit is stored to idx.
startUses start as starting point to search.
Returns
True if a bit was found.

Definition at line 84 of file bitset.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void tasks::tools::bitset::set ( int_type  p)
inline

Set a bit.

Definition at line 45 of file bitset.h.

Here is the caller graph for this function:

bool tasks::tools::bitset::test ( int_type  p) const
inline

Test if a bit is set.

Definition at line 57 of file bitset.h.

Here is the caller graph for this function:

std::string tasks::tools::bitset::to_string ( )
inline

Return a string representation.

Definition at line 104 of file bitset.h.

Here is the call graph for this function:

void tasks::tools::bitset::toggle ( int_type  p)
inline

Toggle a bit.

Definition at line 39 of file bitset.h.

Here is the caller graph for this function:

void tasks::tools::bitset::unset ( int_type  p)
inline

Unset a bit.

Definition at line 51 of file bitset.h.

Here is the caller graph for this function:

Member Data Documentation

int_type tasks::tools::bitset::m_bits
private

Definition at line 117 of file bitset.h.

std::vector<data_type> tasks::tools::bitset::m_bitset
private

Definition at line 116 of file bitset.h.


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