Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::BitSet Class Reference

represents a bitset based on roaring bitmaps provided by the CRoaring library More...

#include <bitset.h>

+ Inheritance diagram for inviwo::BitSet:

Classes

class  BitSetIterator
 

Public Types

template<typename T >
using iterator_category = typename std::iterator_traits<T>::iterator_category
 
template<class T >
using is_iterator = util::is_detected<iterator_category, T>
 

Public Member Functions

 BitSet (std::span< const uint32_t > span)
 
 BitSet (const std::vector< bool > &v)
 
template<typename InputIt , class = std::enable_if_t<is_iterator<InputIt>::value>>
 BitSet (InputIt begin, InputIt end)
 
template<typename... Ts, class = std::enable_if_t< std::conjunction<std::is_convertible<Ts, uint32_t>...>::value>>
 BitSet (Ts &&... values)
 
 BitSet (const BitSet &rhs)
 
 BitSet (BitSet &&rhs) noexcept
 
BitSetoperator= (const BitSet &rhs)
 
BitSetoperator= (BitSet &&rhs) noexcept
 
BitSetIterator begin () const
 
BitSetIterator end () const
 
uint32_t cardinality () const
 
size_t size () const
 
bool empty () const
 
void clear ()
 
bool isSubsetOf (const BitSet &b) const
 
bool isStrictSubsetOf (const BitSet &b) const
 
bool set (const BitSet &b)
 
void add (std::span< const uint32_t > span)
 
void add (const std::vector< bool > &v)
 
template<typename InputIt , class = typename std::enable_if_t<is_iterator<InputIt>::value>>
void add (InputIt begin, InputIt end)
 
template<typename... Ts, typename = std::enable_if_t<std::conjunction_v<std::is_convertible<Ts, uint32_t>...>>>
void add (Ts &&... values)
 
bool addChecked (uint32_t v)
 
void addRange (uint32_t min, uint32_t max)
 
void addRangeClosed (uint32_t min, uint32_t max)
 
void remove (uint32_t v)
 
bool removeChecked (uint32_t v)
 
uint32_t max () const
 
uint32_t min () const
 
bool contains (uint32_t v) const
 
bool containsRange (uint32_t min, uint32_t max) const
 
void flip (uint32_t v)
 
void flipRange (uint32_t min, uint32_t max)
 
size_t rank (uint32_t v) const
 
bool operator== (const BitSet &b) const
 
bool operator!= (const BitSet &b) const
 
bool intersect (const BitSet &b) const
 
size_t orCardinality (const BitSet &b) const
 
size_t andCardinality (const BitSet &b) const
 
size_t andNotCardinality (const BitSet &b) const
 
size_t xorCardinality (const BitSet &b) const
 
double jaccardIndex (const BitSet &b) const
 
BitSetoperator&= (const BitSet &b)
 
BitSet operator& (const BitSet &b) const
 
BitSetoperator-= (const BitSet &b)
 
BitSet operator- (const BitSet &b) const
 
BitSetoperator|= (const BitSet &b)
 
BitSet operator| (const BitSet &b) const
 
BitSetoperator^= (const BitSet &b)
 
BitSet operator^ (const BitSet &b) const
 
std::vector< uint32_t > toVector () const
 
std::string toString () const
 
size_t getSizeInBytes () const
 
void writeData (std::ostream &os) const
 
void readData (std::istream &is)
 
void optimize ()
 
void removeRLECompression ()
 
size_t shrinkToFit ()
 
virtual void serialize (Serializer &s) const override
 
virtual void deserialize (Deserializer &d) override
 
- Public Member Functions inherited from inviwo::Serializable

Static Public Member Functions

static BitSet fastUnion (std::span< const BitSet * > bitsets)
 

Friends

std::ostream & operator<< (std::ostream &os, const BitSet &b)
 

Detailed Description

represents a bitset based on roaring bitmaps provided by the CRoaring library

Member Function Documentation

◆ add()

template<typename... Ts, typename = std::enable_if_t<std::conjunction_v<std::is_convertible<Ts, uint32_t>...>>>
void inviwo::BitSet::add ( Ts &&... values)
inline

Add value(s) values to the bitset

Parameters
valuesone or more values

◆ addChecked()

bool inviwo::BitSet::addChecked ( uint32_t v)

Add value v to the bitset and return true on success

Parameters
vvalue
Returns
true if v was added, false if it already existed in the bitset

◆ addRange()

void inviwo::BitSet::addRange ( uint32_t min,
uint32_t max )

Adds all values from the open range [min,max)

Parameters
minlower bound
maxupper bound (not included)

◆ addRangeClosed()

void inviwo::BitSet::addRangeClosed ( uint32_t min,
uint32_t max )

Adds all values from the closed range [min,max]

Parameters
minlower bound
maxupper bound (included)

◆ andCardinality()

size_t inviwo::BitSet::andCardinality ( const BitSet & b) const

Compute the cardinality of the intersection between this bitset and b

◆ andNotCardinality()

size_t inviwo::BitSet::andNotCardinality ( const BitSet & b) const

Compute the cardinality of the difference between this bitset and b

◆ cardinality()

uint32_t inviwo::BitSet::cardinality ( ) const

Return the number of elements the bitset holds

See also
size()

◆ contains()

bool inviwo::BitSet::contains ( uint32_t v) const

Checks whether v is part of the bitset

Parameters
vvalue to check
Returns
true if v exists

◆ containsRange()

bool inviwo::BitSet::containsRange ( uint32_t min,
uint32_t max ) const

Checks whether the open range [min, max) is part of the bitset

Parameters
minlower bound
maxupper bound
Returns
true if [min, max) exists

◆ deserialize()

virtual void inviwo::BitSet::deserialize ( Deserializer & d)
overridevirtual

Implements inviwo::Serializable.

◆ fastUnion()

static BitSet inviwo::BitSet::fastUnion ( std::span< const BitSet * > bitsets)
static

compute the union of multiple bitsets

◆ flip()

void inviwo::BitSet::flip ( uint32_t v)

Flip the value v, that is add it to the bitset if not part of it, otherwise remove it

Parameters
vvalue to flip

◆ flipRange()

void inviwo::BitSet::flipRange ( uint32_t min,
uint32_t max )

Flip all bits in the open range [min, max)

◆ getSizeInBytes()

size_t inviwo::BitSet::getSizeInBytes ( ) const

Return the number of bytes required to serialize the bitset

See also
optimize(), shrinkToFit()

◆ intersect()

bool inviwo::BitSet::intersect ( const BitSet & b) const

Checks whether this bitset and b intersect

◆ isStrictSubsetOf()

bool inviwo::BitSet::isStrictSubsetOf ( const BitSet & b) const

Check whether this bitset is a strict subset of b

◆ isSubsetOf()

bool inviwo::BitSet::isSubsetOf ( const BitSet & b) const

Check whether this bitset is a subset of b

◆ jaccardIndex()

double inviwo::BitSet::jaccardIndex ( const BitSet & b) const

Computes the Jaccard index between this bitset and b. This distance is also known as the Tanimoto distance, or the Jaccard similarity coefficient.

The Jaccard index is undefined if both bitsets are empty.

◆ max()

uint32_t inviwo::BitSet::max ( ) const

Return the largest value

Returns
largest value in the bitset, 0 if empty

◆ min()

uint32_t inviwo::BitSet::min ( ) const

Return the smallest value

Returns
smallest value in the bitset, UINT32_MAX if empty

◆ operator!=()

bool inviwo::BitSet::operator!= ( const BitSet & b) const

Compare whether this bitset and b are different

◆ operator&()

BitSet inviwo::BitSet::operator& ( const BitSet & b) const

Intersection of this bitset and b

◆ operator&=()

BitSet & inviwo::BitSet::operator&= ( const BitSet & b)

Intersection of this bitset and b

◆ operator-()

BitSet inviwo::BitSet::operator- ( const BitSet & b) const

Difference of this bitset and b

◆ operator-=()

BitSet & inviwo::BitSet::operator-= ( const BitSet & b)

Difference of this bitset and b

◆ operator==()

bool inviwo::BitSet::operator== ( const BitSet & b) const

Compare whether this bitset and b are identical

◆ operator^()

BitSet inviwo::BitSet::operator^ ( const BitSet & b) const

Symmetric union of this bitset and b

◆ operator^=()

BitSet & inviwo::BitSet::operator^= ( const BitSet & b)

Symmetric union of this bitset and b

◆ operator|()

BitSet inviwo::BitSet::operator| ( const BitSet & b) const

Union of this bitset and b

◆ operator|=()

BitSet & inviwo::BitSet::operator|= ( const BitSet & b)

Union of this bitset and b

◆ optimize()

void inviwo::BitSet::optimize ( )

Optimize the bitset representation using run-length encoding based on space efficiency. Calling shrinkToFit() might result in further memory savings.

◆ orCardinality()

size_t inviwo::BitSet::orCardinality ( const BitSet & b) const

Compute the cardinality of the union between this bitset and b

◆ rank()

size_t inviwo::BitSet::rank ( uint32_t v) const

Return the number of values that are less or equal to v

◆ readData()

void inviwo::BitSet::readData ( std::istream & is)

Read a BitSet from stream is. The first four byte value contains the size of the bitset in bytes.

Exceptions
Exception

◆ remove()

void inviwo::BitSet::remove ( uint32_t v)

Remove value v to the bitset

Parameters
vvalue

◆ removeChecked()

bool inviwo::BitSet::removeChecked ( uint32_t v)

Remove value v to the bitset and return true on success

Parameters
vvalue
Returns
true if v was removed, false if it did not exist in the bitset

◆ removeRLECompression()

void inviwo::BitSet::removeRLECompression ( )

Enforce removing the run-length encoding of the bitset even though it might be more efficient.

See also
optimize()

◆ serialize()

virtual void inviwo::BitSet::serialize ( Serializer & s) const
overridevirtual

Implements inviwo::Serializable.

◆ set()

bool inviwo::BitSet::set ( const BitSet & b)

Replace the bitset with the contents of b, returns true if modified

Returns
true if the bitset was modified that is this and b were different

◆ shrinkToFit()

size_t inviwo::BitSet::shrinkToFit ( )

Reallocates the memory needed.

Returns
number of bytes saved

◆ size()

size_t inviwo::BitSet::size ( ) const

Return the number of elements the bitset holds

See also
cardinality()

◆ toString()

std::string inviwo::BitSet::toString ( ) const

Create a string from the bitset

◆ toVector()

std::vector< uint32_t > inviwo::BitSet::toVector ( ) const

Convert bitset to a std::vector holding only set elements. The output is ordered.

◆ writeData()

void inviwo::BitSet::writeData ( std::ostream & os) const

Write this bitset to stream os. The first four byte value contains the size of the bitset in bytes followed by the binary encoding.

◆ xorCardinality()

size_t inviwo::BitSet::xorCardinality ( const BitSet & b) const

Compute the cardinality of the symmetric difference between this bitset and b


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