PackedBoolList Class Reference

A bit-packed bool list. More...

Inheritance diagram for PackedBoolList:
Collaboration diagram for PackedBoolList:

Public Member Functions

 PackedBoolList ()
 Construct null. More...
 
 PackedBoolList (Istream &)
 Construct from Istream. More...
 
 PackedBoolList (const label size)
 Construct with given size, initialises list to 0. More...
 
 PackedBoolList (const label size, const bool val)
 Construct with given size and value for all elements. More...
 
 PackedBoolList (const PackedBoolList &)
 Copy constructor. More...
 
 PackedBoolList (const PackedList< 1 > &)
 Copy constructor. More...
 
 PackedBoolList (const Foam::UList< bool > &)
 Construct from a list of bools. More...
 
 PackedBoolList (const labelUList &indices)
 Construct from a list of labels. More...
 
 PackedBoolList (const UIndirectList< label > &indices)
 Construct from a list of labels. More...
 
autoPtr< PackedBoolListclone () const
 Clone. More...
 
void set (const PackedList< 1 > &)
 Set specified bits. More...
 
label set (const labelUList &indices)
 Set the listed indices. Return number of elements changed. More...
 
label set (const UIndirectList< label > &indices)
 Set the listed indices. Return number of elements changed. More...
 
void unset (const PackedList< 1 > &)
 Unset specified bits. More...
 
label unset (const labelUList &indices)
 Unset the listed indices. Return number of elements changed. More...
 
label unset (const UIndirectList< label > &indices)
 Unset the listed indices. Return number of elements changed. More...
 
void subset (const PackedList< 1 > &)
 Subset with the specified list. More...
 
label subset (const labelUList &indices)
 Subset with the listed indices. More...
 
label subset (const UIndirectList< label > &indices)
 Subset with the listed indices. More...
 
labelList used () const
 Return indices of the used (true) elements as a list of labels. More...
 
void transfer (PackedBoolList &)
 Transfer the contents of the argument list into this list. More...
 
void transfer (PackedList< 1 > &)
 Transfer the contents of the argument list into this list. More...
 
void operator= (const bool val)
 Assignment of all entries to the given value. More...
 
void operator= (const PackedBoolList &)
 Assignment operator. More...
 
void operator= (const PackedList< 1 > &)
 Assignment operator. More...
 
void operator= (const Foam::UList< bool > &)
 Assignment operator. More...
 
void operator= (const labelUList &indices)
 Assignment operator,. More...
 
void operator= (const UIndirectList< label > &)
 Assignment operator,. More...
 
PackedBoolList operator~ () const
 Complement operator. More...
 
PackedBoolListoperator &= (const PackedList< 1 > &)
 And operator (lists may be dissimilar sizes) More...
 
PackedBoolListoperator &= (const labelUList &indices)
 And operator (lists may be dissimilar sizes) More...
 
PackedBoolListoperator &= (const UIndirectList< label > &)
 And operator (lists may be dissimilar sizes) More...
 
PackedBoolListoperator^= (const PackedList< 1 > &)
 Xor operator (lists may be dissimilar sizes) More...
 
PackedBoolListoperator|= (const PackedList< 1 > &)
 Or operator (lists may be dissimilar sizes) More...
 
PackedBoolListoperator|= (const labelUList &indices)
 Or operator (lists may be dissimilar sizes),. More...
 
PackedBoolListoperator|= (const UIndirectList< label > &)
 Or operator (lists may be dissimilar sizes),. More...
 
PackedBoolListoperator+= (const PackedList< 1 > &)
 Add entries to this list, synonymous with the or operator. More...
 
PackedBoolListoperator+= (const labelUList &indices)
 Add entries to this list, synonymous with the or operator. More...
 
PackedBoolListoperator+= (const UIndirectList< label > &)
 Add entries to this list, synonymous with the or operator. More...
 
PackedBoolListoperator-= (const PackedList< 1 > &)
 Remove entries from this list - unset the specified bits. More...
 
PackedBoolListoperator-= (const labelUList &indices)
 Remove entries from this list - unset the specified bits. More...
 
PackedBoolListoperator-= (const UIndirectList< label > &)
 Remove entries from this list - unset the specified bits. More...
 
template<class LabelListType >
Foam::label setIndices (const LabelListType &indices)
 
template<class LabelListType >
Foam::label unsetIndices (const LabelListType &indices)
 
template<class LabelListType >
Foam::label subsetIndices (const LabelListType &indices)
 
- Public Member Functions inherited from PackedList< 1 >
label packedLength () const
 The list length when packed. More...
 
 PackedList ()
 Null constructor. More...
 
 PackedList (const label size)
 Construct with given size, initialises list to 0. More...
 
 PackedList (const label size, const unsigned val)
 Construct with given size and value for all elements. More...
 
 PackedList (Istream &)
 Construct from Istream. More...
 
 PackedList (const PackedList< nBits > &)
 Copy constructor. More...
 
 PackedList (PackedList< nBits > &&)
 Move constructor. More...
 
 PackedList (const labelUList &)
 Construct from a list of labels. More...
 
 PackedList (const UIndirectList< label > &)
 Construct from an indirect list of labels. More...
 
autoPtr< PackedList< nBits > > clone () const
 Clone. More...
 
label capacity () const
 The number of elements that can be stored before reallocating. More...
 
label size () const
 Number of entries. More...
 
bool empty () const
 Return true if the list is empty (ie, size() is zero). More...
 
unsigned int get (const label) const
 Get value at index I. More...
 
bool set (const label, const unsigned int val=~0u)
 Set value at index I. Return true if value changed. More...
 
bool unset (const label)
 Unset the entry at index I. Return true if value changed. More...
 
List< unsigned int > & storage ()
 Return the underlying packed storage. More...
 
const List< unsigned int > & storage () const
 Return the underlying packed storage. More...
 
std::streamsize byteSize () const
 Return the binary size in number of characters. More...
 
unsigned int count () const
 Count number of bits set, O(log(n)) More...
 
labelList values () const
 Return the values as a list of labels. More...
 
OstreamprintBits (Ostream &, const bool fullOutput=false) const
 Print bit patterns, optionally output unused elements. More...
 
OstreamprintInfo (Ostream &, const bool fullOutput=false) const
 Print information and bit patterns (with printBits) More...
 
bool trim ()
 Trim any trailing zero elements. More...
 
void flip ()
 Invert the bits in the addressable region. More...
 
void reset ()
 Clear all bits. More...
 
void setCapacity (const label)
 Alter the size of the underlying storage. More...
 
void resize (const label, const unsigned int &val=0u)
 Reset addressable list size, does not shrink the allocated size. More...
 
void setSize (const label, const unsigned int &val=0u)
 Alias for resize() More...
 
void reserve (const label)
 Reserve allocation space for at least this size. More...
 
void clear ()
 Clear the list, i.e. set addressable size to zero. More...
 
void clearStorage ()
 Clear the list and delete storage. More...
 
void shrink ()
 Shrink the allocated space to what is actually used. More...
 
void transfer (PackedList< nBits > &)
 Transfer the contents of the argument list into this list. More...
 
Istreamread (Istream &)
 Clear list and read from stream. More...
 
Ostreamwrite (Ostream &, const bool indexedOutput=false) const
 Write, optionally with indexedOutput. More...
 
PackedList< nBits > & append (const unsigned int val)
 Append a value at the end of the list. More...
 
unsigned int remove ()
 Remove and return the last element. More...
 
unsigned int operator[] (const label) const
 Get value at index I. More...
 
iteratorBase operator[] (const label)
 Set value at index I. More...
 
void operator= (const unsigned int val)
 Assignment of all entries to the given value. Takes linear time. More...
 
void operator= (const PackedList< nBits > &)
 Assignment operator. More...
 
void operator= (PackedList< nBits > &&)
 Move assignment operator. More...
 
void operator= (const labelUList &)
 Assignment operator. More...
 
void operator= (const UIndirectList< label > &)
 Assignment operator. More...
 
iterator begin ()
 Iterator set to the beginning of the PackedList. More...
 
const_iterator begin () const
 const_iterator set to the beginning of the PackedList More...
 
iterator end ()
 Iterator set to beyond the end of the PackedList. More...
 
const_iterator end () const
 const_iterator set to beyond the end of the PackedList More...
 
const_iterator cbegin () const
 const_iterator set to the beginning of the PackedList More...
 
const_iterator cend () const
 const_iterator set to beyond the end of the PackedList More...
 
- Public Member Functions inherited from PackedListCore
 PackedListCore ()
 Construct null. More...
 
 ClassName ("PackedList")
 Define template name and debug. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from PackedList< 1 >
static unsigned int max_bits ()
 The max. number of bits that can be templated. More...
 
static unsigned int max_value ()
 The max. value for an entry, which simultaneously the bit-mask. More...
 
static unsigned int packing ()
 The number of entries per packed storage element. More...
 
static unsigned int maskLower (unsigned offset)
 Masking for all bits below the offset. More...
 
- Protected Types inherited from PackedList< 1 >
typedef unsigned int StorageType
 
typedef List< StorageTypeStorageList
 
- Protected Member Functions inherited from PackedList< 1 >
unsigned int readValue (Istream &is)
 
void setPair (Istream &)
 Read an index/value pair and set accordingly. More...
 
void setPair (Istream &is)
 
- Static Protected Member Functions inherited from PackedList< 1 >
static label packedLength (const label)
 Calculate the list length when packed. More...
 
static unsigned int readValue (Istream &)
 Read a list entry (allows for specialisation) More...
 

Detailed Description

A bit-packed bool list.

In addition to the obvious memory advantage over using a List<bool>, this class also provides a number of bit-like operations.

Source files
See also
Foam::PackedList

Definition at line 63 of file PackedBoolList.H.

Constructor & Destructor Documentation

◆ PackedBoolList() [1/9]

PackedBoolList ( )
inline

Construct null.

Definition at line 28 of file PackedBoolListI.H.

Referenced by PackedBoolList::clone(), and PackedBoolList::PackedBoolList().

Here is the caller graph for this function:

◆ PackedBoolList() [2/9]

Construct from Istream.

Definition at line 159 of file PackedBoolList.C.

◆ PackedBoolList() [3/9]

PackedBoolList ( const label  size)
inlineexplicit

Construct with given size, initialises list to 0.

Definition at line 34 of file PackedBoolListI.H.

References PackedBoolList::PackedBoolList().

Here is the call graph for this function:

◆ PackedBoolList() [4/9]

PackedBoolList ( const label  size,
const bool  val 
)
inline

Construct with given size and value for all elements.

Definition at line 41 of file PackedBoolListI.H.

◆ PackedBoolList() [5/9]

PackedBoolList ( const PackedBoolList lst)
inline

Copy constructor.

Definition at line 50 of file PackedBoolListI.H.

◆ PackedBoolList() [6/9]

PackedBoolList ( const PackedList< 1 > &  lst)
inlineexplicit

Copy constructor.

Definition at line 56 of file PackedBoolListI.H.

◆ PackedBoolList() [7/9]

PackedBoolList ( const Foam::UList< bool > &  lst)
inlineexplicit

Construct from a list of bools.

Definition at line 62 of file PackedBoolListI.H.

References PackedBoolList::operator=().

Here is the call graph for this function:

◆ PackedBoolList() [8/9]

PackedBoolList ( const labelUList indices)
inlineexplicit

Construct from a list of labels.

using the labels as indices to indicate which bits are set

Definition at line 70 of file PackedBoolListI.H.

◆ PackedBoolList() [9/9]

PackedBoolList ( const UIndirectList< label > &  indices)
inlineexplicit

Construct from a list of labels.

using the labels as indices to indicate which bits are set

Definition at line 78 of file PackedBoolListI.H.

Member Function Documentation

◆ clone()

Foam::autoPtr< Foam::PackedBoolList > clone ( ) const
inline

Clone.

Definition at line 87 of file PackedBoolListI.H.

References PackedBoolList::PackedBoolList().

Here is the call graph for this function:

◆ set() [1/3]

◆ set() [2/3]

Foam::label set ( const labelUList indices)

Set the listed indices. Return number of elements changed.

Does auto-vivify for non-existent entries.

Definition at line 191 of file PackedBoolList.C.

◆ set() [3/3]

Foam::label set ( const UIndirectList< label > &  indices)

Set the listed indices. Return number of elements changed.

Does auto-vivify for non-existent entries.

Definition at line 197 of file PackedBoolList.C.

◆ unset() [1/3]

void unset ( const PackedList< 1 > &  lst)

Unset specified bits.

Definition at line 203 of file PackedBoolList.C.

References Foam::min(), PackedList< nBits >::packedLength(), PackedList< 1 >::packedLength(), PackedList< 1 >::storage(), and PackedList< nBits >::storage().

Referenced by hexRef8::faceLevel(), PackedBoolList::operator-=(), PackedBoolList::unsetIndices(), and refiner::update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unset() [2/3]

Foam::label unset ( const labelUList indices)

Unset the listed indices. Return number of elements changed.

Never auto-vivify entries.

Definition at line 219 of file PackedBoolList.C.

◆ unset() [3/3]

Foam::label unset ( const UIndirectList< label > &  indices)

Unset the listed indices. Return number of elements changed.

Never auto-vivify entries.

Definition at line 225 of file PackedBoolList.C.

◆ subset() [1/3]

void subset ( const PackedList< 1 > &  lst)

Subset with the specified list.

Definition at line 231 of file PackedBoolList.C.

References PackedList< 1 >::packedLength(), PackedList< 1 >::resize(), PackedList< nBits >::size(), PackedList< 1 >::size(), PackedList< 1 >::storage(), and PackedList< nBits >::storage().

Referenced by PackedBoolList::operator~().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ subset() [2/3]

Foam::label subset ( const labelUList indices)

Subset with the listed indices.

Return number of elements subsetted.

Definition at line 252 of file PackedBoolList.C.

◆ subset() [3/3]

Foam::label subset ( const UIndirectList< label > &  indices)

Subset with the listed indices.

Return number of elements subsetted.

Definition at line 258 of file PackedBoolList.C.

◆ used()

Foam::labelList used ( ) const

Return indices of the used (true) elements as a list of labels.

Definition at line 264 of file PackedBoolList.C.

References PackedList< 1 >::count(), forAll, List< T >::setSize(), and List< T >::size().

Here is the call graph for this function:

◆ transfer() [1/2]

void transfer ( PackedBoolList lst)
inline

Transfer the contents of the argument list into this list.

and annul the argument list.

Definition at line 95 of file PackedBoolListI.H.

References PackedList< nBits >::transfer().

Referenced by PackedBoolList::subsetIndices(), and refiner::update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transfer() [2/2]

void transfer ( PackedList< 1 > &  lst)
inline

Transfer the contents of the argument list into this list.

and annul the argument list.

Definition at line 101 of file PackedBoolListI.H.

References PackedList< nBits >::transfer().

Here is the call graph for this function:

◆ operator=() [1/6]

void operator= ( const bool  val)
inline

Assignment of all entries to the given value.

Definition at line 109 of file PackedBoolListI.H.

References PackedList< nBits >::operator=().

Referenced by PackedBoolList::PackedBoolList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [2/6]

void operator= ( const PackedBoolList lst)
inline

Assignment operator.

Definition at line 115 of file PackedBoolListI.H.

References PackedList< nBits >::operator=().

Here is the call graph for this function:

◆ operator=() [3/6]

void operator= ( const PackedList< 1 > &  lst)
inline

Assignment operator.

Definition at line 121 of file PackedBoolListI.H.

References PackedList< nBits >::operator=().

Here is the call graph for this function:

◆ operator=() [4/6]

void operator= ( const Foam::UList< bool > &  lst)

Assignment operator.

Definition at line 289 of file PackedBoolList.C.

References forAll, PackedList< 1 >::setSize(), and UList< T >::size().

Here is the call graph for this function:

◆ operator=() [5/6]

void operator= ( const labelUList indices)
inline

Assignment operator,.

using the labels as indices to indicate which bits are set

Definition at line 127 of file PackedBoolListI.H.

References PackedList< 1 >::clear().

Here is the call graph for this function:

◆ operator=() [6/6]

void operator= ( const UIndirectList< label > &  indices)
inline

Assignment operator,.

using the labels as indices to indicate which bits are set

Definition at line 134 of file PackedBoolListI.H.

References PackedList< 1 >::clear().

Here is the call graph for this function:

◆ operator~()

Foam::PackedBoolList operator~ ( ) const
inline

Complement operator.

Definition at line 142 of file PackedBoolListI.H.

References PackedList< nBits >::flip(), PackedBoolList::operator &=(), and PackedBoolList::subset().

Here is the call graph for this function:

◆ operator &=() [1/3]

PackedBoolList& operator&= ( const PackedList< 1 > &  )
inline

And operator (lists may be dissimilar sizes)

Referenced by PackedBoolList::operator~().

Here is the caller graph for this function:

◆ operator &=() [2/3]

PackedBoolList& operator&= ( const labelUList indices)
inline

And operator (lists may be dissimilar sizes)

using the labels as indices to indicate which bits are set

◆ operator &=() [3/3]

PackedBoolList& operator&= ( const UIndirectList< label > &  )
inline

And operator (lists may be dissimilar sizes)

using the labels as indices to indicate which bits are set

◆ operator^=()

Foam::PackedBoolList & operator^= ( const PackedList< 1 > &  lst)

Xor operator (lists may be dissimilar sizes)

Retains unique entries

Definition at line 302 of file PackedBoolList.C.

References PackedList< 1 >::storage(), PackedList< nBits >::storage(), PackedList< 1 >::trim(), and PackedList< nBits >::trim().

Here is the call graph for this function:

◆ operator|=() [1/3]

Foam::PackedBoolList & operator|= ( const PackedList< 1 > &  lst)
inline

Or operator (lists may be dissimilar sizes)

Definition at line 176 of file PackedBoolListI.H.

Referenced by PackedBoolList::operator+=().

Here is the caller graph for this function:

◆ operator|=() [2/3]

Foam::PackedBoolList & operator|= ( const labelUList indices)
inline

Or operator (lists may be dissimilar sizes),.

using the labels as indices to indicate which bits are set

Definition at line 184 of file PackedBoolListI.H.

◆ operator|=() [3/3]

Foam::PackedBoolList & operator|= ( const UIndirectList< label > &  indices)
inline

Or operator (lists may be dissimilar sizes),.

using the labels as indices to indicate which bits are set

Definition at line 192 of file PackedBoolListI.H.

◆ operator+=() [1/3]

Foam::PackedBoolList & operator+= ( const PackedList< 1 > &  lst)
inline

Add entries to this list, synonymous with the or operator.

Definition at line 200 of file PackedBoolListI.H.

References PackedBoolList::operator|=().

Here is the call graph for this function:

◆ operator+=() [2/3]

Foam::PackedBoolList & operator+= ( const labelUList indices)
inline

Add entries to this list, synonymous with the or operator.

Definition at line 207 of file PackedBoolListI.H.

References PackedBoolList::operator|=().

Here is the call graph for this function:

◆ operator+=() [3/3]

Foam::PackedBoolList & operator+= ( const UIndirectList< label > &  indices)
inline

Add entries to this list, synonymous with the or operator.

Definition at line 214 of file PackedBoolListI.H.

References PackedBoolList::operator|=().

Here is the call graph for this function:

◆ operator-=() [1/3]

Foam::PackedBoolList & operator-= ( const PackedList< 1 > &  lst)
inline

Remove entries from this list - unset the specified bits.

Definition at line 221 of file PackedBoolListI.H.

References PackedBoolList::unset().

Here is the call graph for this function:

◆ operator-=() [2/3]

Foam::PackedBoolList & operator-= ( const labelUList indices)
inline

Remove entries from this list - unset the specified bits.

Definition at line 229 of file PackedBoolListI.H.

References PackedBoolList::unset().

Here is the call graph for this function:

◆ operator-=() [3/3]

Foam::PackedBoolList & operator-= ( const UIndirectList< label > &  indices)
inline

Remove entries from this list - unset the specified bits.

Definition at line 237 of file PackedBoolListI.H.

References PackedBoolList::unset().

Here is the call graph for this function:

◆ setIndices()

Foam::label setIndices ( const LabelListType &  indices)

Definition at line 93 of file PackedBoolList.C.

References forAll, and PackedList< 1 >::reserve().

Here is the call graph for this function:

◆ unsetIndices()

Foam::label unsetIndices ( const LabelListType &  indices)

Definition at line 112 of file PackedBoolList.C.

References forAll, and PackedBoolList::unset().

Here is the call graph for this function:

◆ subsetIndices()

Foam::label subsetIndices ( const LabelListType &  indices)

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