EWAHBoolArray 0.8.0
A compressed bitmap class in C++
Loading...
Searching...
No Matches
ewah::BoolArray< uword > Class Template Reference

A dynamic bitset implementation. More...

#include <boolarray.h>

Public Types

enum  { wordinbits = sizeof(uword) * 8 }
 

Public Member Functions

 BoolArray (const size_t n, const uword initval=0)
 
 BoolArray (const BoolArray &ba)
 
size_t sizeInBytes () const
 
void read (std::istream &in)
 
void readBuffer (std::istream &in, const size_t size)
 
void setSizeInBits (const size_t sizeib)
 
void write (std::ostream &out)
 
void write (std::ostream &out, const size_t numberofbits) const
 
void writeBuffer (std::ostream &out, const size_t numberofbits) const
 
size_t sizeOnDisk () const
 
BoolArrayoperator= (const BoolArray &x)
 
bool operator== (const BoolArray &x) const
 
bool operator!= (const BoolArray &x) const
 
void setWord (const size_t pos, const uword val)
 
void addWord (const uword val)
 
uword getWord (const size_t pos) const
 
void set (const size_t pos)
 set to true (whether it was already set to true or not)
 
void unset (const size_t pos)
 set to false (whether it was already set to false or not)
 
bool get (const size_t pos) const
 true of false? (set or unset)
 
void reset ()
 set all bits to 0
 
size_t sizeInBits () const
 
void logicaland (const BoolArray &ba, BoolArray &out) const
 Computes the logical and and writes to the provided BoolArray (out).
 
BoolArray logicaland (const BoolArray &a) const
 Computes the logical and and return the result.
 
void inplace_logicaland (const BoolArray &ba)
 
void logicalandnot (const BoolArray &ba, BoolArray &out) const
 Computes the logical andnot and writes to the provided BoolArray (out).
 
BoolArray logicalandnot (const BoolArray &a) const
 Computes the logical andnot and return the result.
 
void inplace_logicalandnot (const BoolArray &ba)
 
void logicalor (const BoolArray &ba, BoolArray &out) const
 Computes the logical or and writes to the provided BoolArray (out).
 
BoolArray logicalor (const BoolArray &a) const
 Computes the logical or and return the result.
 
void inplace_logicalor (const BoolArray &ba)
 
void logicalxor (const BoolArray &ba, BoolArray &out) const
 Computes the logical xor and writes to the provided BoolArray (out).
 
BoolArray logicalxor (const BoolArray &a) const
 Computes the logical xor and return the result.
 
void inplace_logicalxor (const BoolArray &ba)
 
void logicalnot (BoolArray &out) const
 Computes the logical not and writes to the provided BoolArray (out).
 
BoolArray logicalandnot () const
 Computes the logical not and return the result.
 
void inplace_logicalnot ()
 
size_t numberOfOnes () const
 Returns the number of bits set to the value 1.
 
void printout (std::ostream &o=std::cout)
 
void makeSameSize (BoolArray &a)
 Make sure the two bitmaps have the same size (padding with zeroes if necessary).
 
void setToSize (const BoolArray &a)
 Make sure the current bitmap has the size of the provided bitmap.
 
size_t padWithZeroes (const size_t totalbits)
 make sure the size of the array is totalbits bits by padding with zeroes.
 
void append (const BoolArray &a)
 
std::vector< size_t > toArray () const
 
 operator std::string () const
 Transform into a string that presents a list of set bits.
 

Static Public Member Functions

static BoolArray bitmapOf (size_t n,...)
 

Detailed Description

template<class uword = uint32_t>
class ewah::BoolArray< uword >

A dynamic bitset implementation.

(without compression).

Definition at line 19 of file boolarray.h.

Member Enumeration Documentation

◆ anonymous enum

template<class uword = uint32_t>
anonymous enum

Definition at line 389 of file boolarray.h.

Constructor & Destructor Documentation

◆ BoolArray() [1/3]

template<class uword = uint32_t>
ewah::BoolArray< uword >::BoolArray ( const size_t n,
const uword initval = 0 )
inline

Definition at line 21 of file boolarray.h.

◆ BoolArray() [2/3]

template<class uword = uint32_t>
ewah::BoolArray< uword >::BoolArray ( )
inline

Definition at line 25 of file boolarray.h.

◆ BoolArray() [3/3]

template<class uword = uint32_t>
ewah::BoolArray< uword >::BoolArray ( const BoolArray< uword > & ba)
inline

Definition at line 27 of file boolarray.h.

◆ ~BoolArray()

template<class uword = uint32_t>
ewah::BoolArray< uword >::~BoolArray ( )
inline

Definition at line 173 of file boolarray.h.

Member Function Documentation

◆ addWord()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::addWord ( const uword val)
inline

Definition at line 117 of file boolarray.h.

◆ append()

template<class uword >
void ewah::BoolArray< uword >::append ( const BoolArray< uword > & a)

Definition at line 474 of file boolarray.h.

◆ bitmapOf()

template<class uword = uint32_t>
static BoolArray ewah::BoolArray< uword >::bitmapOf ( size_t n,
... )
inlinestatic

Definition at line 29 of file boolarray.h.

◆ get()

template<class uword = uint32_t>
bool ewah::BoolArray< uword >::get ( const size_t pos) const
inline

true of false? (set or unset)

Definition at line 154 of file boolarray.h.

◆ getWord()

template<class uword = uint32_t>
uword ewah::BoolArray< uword >::getWord ( const size_t pos) const
inline

Definition at line 124 of file boolarray.h.

◆ inplace_logicaland()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::inplace_logicaland ( const BoolArray< uword > & ba)
inline

Definition at line 198 of file boolarray.h.

◆ inplace_logicalandnot()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::inplace_logicalandnot ( const BoolArray< uword > & ba)
inline

Definition at line 230 of file boolarray.h.

◆ inplace_logicalnot()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::inplace_logicalnot ( )
inline

Definition at line 327 of file boolarray.h.

◆ inplace_logicalor()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::inplace_logicalor ( const BoolArray< uword > & ba)
inline

Definition at line 270 of file boolarray.h.

◆ inplace_logicalxor()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::inplace_logicalxor ( const BoolArray< uword > & ba)
inline

Definition at line 304 of file boolarray.h.

◆ logicaland() [1/2]

template<class uword = uint32_t>
BoolArray ewah::BoolArray< uword >::logicaland ( const BoolArray< uword > & a) const
inline

Computes the logical and and return the result.

The current bitmaps is unchanged.

Definition at line 192 of file boolarray.h.

◆ logicaland() [2/2]

template<class uword = uint32_t>
void ewah::BoolArray< uword >::logicaland ( const BoolArray< uword > & ba,
BoolArray< uword > & out ) const
inline

Computes the logical and and writes to the provided BoolArray (out).

The current bitmaps is unchanged.

Definition at line 179 of file boolarray.h.

◆ logicalandnot() [1/3]

template<class uword = uint32_t>
BoolArray ewah::BoolArray< uword >::logicalandnot ( ) const
inline

Computes the logical not and return the result.

The current bitmaps is unchanged.

Definition at line 321 of file boolarray.h.

◆ logicalandnot() [2/3]

template<class uword = uint32_t>
BoolArray ewah::BoolArray< uword >::logicalandnot ( const BoolArray< uword > & a) const
inline

Computes the logical andnot and return the result.

The current bitmaps is unchanged.

Definition at line 224 of file boolarray.h.

◆ logicalandnot() [3/3]

template<class uword = uint32_t>
void ewah::BoolArray< uword >::logicalandnot ( const BoolArray< uword > & ba,
BoolArray< uword > & out ) const
inline

Computes the logical andnot and writes to the provided BoolArray (out).

The current bitmaps is unchanged.

Definition at line 209 of file boolarray.h.

◆ logicalnot()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::logicalnot ( BoolArray< uword > & out) const
inline

Computes the logical not and writes to the provided BoolArray (out).

The current bitmaps is unchanged.

Definition at line 310 of file boolarray.h.

◆ logicalor() [1/2]

template<class uword = uint32_t>
BoolArray ewah::BoolArray< uword >::logicalor ( const BoolArray< uword > & a) const
inline

Computes the logical or and return the result.

The current bitmaps is unchanged.

Definition at line 264 of file boolarray.h.

◆ logicalor() [2/2]

template<class uword = uint32_t>
void ewah::BoolArray< uword >::logicalor ( const BoolArray< uword > & ba,
BoolArray< uword > & out ) const
inline

Computes the logical or and writes to the provided BoolArray (out).

The current bitmaps is unchanged.

Definition at line 242 of file boolarray.h.

◆ logicalxor() [1/2]

template<class uword = uint32_t>
BoolArray ewah::BoolArray< uword >::logicalxor ( const BoolArray< uword > & a) const
inline

Computes the logical xor and return the result.

The current bitmaps is unchanged.

Definition at line 298 of file boolarray.h.

◆ logicalxor() [2/2]

template<class uword = uint32_t>
void ewah::BoolArray< uword >::logicalxor ( const BoolArray< uword > & ba,
BoolArray< uword > & out ) const
inline

Computes the logical xor and writes to the provided BoolArray (out).

The current bitmaps is unchanged.

Definition at line 276 of file boolarray.h.

◆ makeSameSize()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::makeSameSize ( BoolArray< uword > & a)
inline

Make sure the two bitmaps have the same size (padding with zeroes if necessary).

It has constant running time complexity.

Definition at line 358 of file boolarray.h.

◆ numberOfOnes()

template<class uword = uint32_t>
size_t ewah::BoolArray< uword >::numberOfOnes ( ) const
inline

Returns the number of bits set to the value 1.

The running time complexity is proportional to the size of the bitmap.

This is sometimes called the cardinality.

Definition at line 340 of file boolarray.h.

◆ operator std::string()

template<class uword = uint32_t>
ewah::BoolArray< uword >::operator std::string ( ) const
inline

Transform into a string that presents a list of set bits.

The running time is linear in the size of the bitmap.

Definition at line 408 of file boolarray.h.

◆ operator!=()

template<class uword = uint32_t>
bool ewah::BoolArray< uword >::operator!= ( const BoolArray< uword > & x) const
inline

Definition at line 108 of file boolarray.h.

◆ operator=()

template<class uword = uint32_t>
BoolArray & ewah::BoolArray< uword >::operator= ( const BoolArray< uword > & x)
inline

Definition at line 93 of file boolarray.h.

◆ operator==()

template<class uword = uint32_t>
bool ewah::BoolArray< uword >::operator== ( const BoolArray< uword > & x) const
inline

Definition at line 99 of file boolarray.h.

◆ padWithZeroes()

template<class uword = uint32_t>
size_t ewah::BoolArray< uword >::padWithZeroes ( const size_t totalbits)
inline

make sure the size of the array is totalbits bits by padding with zeroes.

returns the number of words added (storage cost increase)

Definition at line 376 of file boolarray.h.

◆ printout()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::printout ( std::ostream & o = std::cout)
inline

Definition at line 348 of file boolarray.h.

◆ read()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::read ( std::istream & in)
inline

Definition at line 41 of file boolarray.h.

◆ readBuffer()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::readBuffer ( std::istream & in,
const size_t size )
inline

Definition at line 52 of file boolarray.h.

◆ reset()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::reset ( )
inline

set all bits to 0

Definition at line 165 of file boolarray.h.

◆ set()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::set ( const size_t pos)
inline

set to true (whether it was already set to true or not)

Definition at line 134 of file boolarray.h.

◆ setSizeInBits()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::setSizeInBits ( const size_t sizeib)
inline

Definition at line 61 of file boolarray.h.

◆ setToSize()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::setToSize ( const BoolArray< uword > & a)
inline

Make sure the current bitmap has the size of the provided bitmap.

Definition at line 367 of file boolarray.h.

◆ setWord()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::setWord ( const size_t pos,
const uword val )
inline

Definition at line 110 of file boolarray.h.

◆ sizeInBits()

template<class uword = uint32_t>
size_t ewah::BoolArray< uword >::sizeInBits ( ) const
inline

Definition at line 171 of file boolarray.h.

◆ sizeInBytes()

template<class uword = uint32_t>
size_t ewah::BoolArray< uword >::sizeInBytes ( ) const
inline

Definition at line 39 of file boolarray.h.

◆ sizeOnDisk()

template<class uword = uint32_t>
size_t ewah::BoolArray< uword >::sizeOnDisk ( ) const
inline

Definition at line 87 of file boolarray.h.

◆ toArray()

template<class uword = uint32_t>
std::vector< size_t > ewah::BoolArray< uword >::toArray ( ) const
inline

Definition at line 391 of file boolarray.h.

◆ unset()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::unset ( const size_t pos)
inline

set to false (whether it was already set to false or not)

Definition at line 145 of file boolarray.h.

◆ write() [1/2]

template<class uword = uint32_t>
void ewah::BoolArray< uword >::write ( std::ostream & out)
inline

Definition at line 63 of file boolarray.h.

◆ write() [2/2]

template<class uword = uint32_t>
void ewah::BoolArray< uword >::write ( std::ostream & out,
const size_t numberofbits ) const
inline

Definition at line 65 of file boolarray.h.

◆ writeBuffer()

template<class uword = uint32_t>
void ewah::BoolArray< uword >::writeBuffer ( std::ostream & out,
const size_t numberofbits ) const
inline

Definition at line 76 of file boolarray.h.


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