A bit-packed bool list. More...
Public Member Functions | |
PackedBoolList () | |
Construct null. More... | |
PackedBoolList (Istream &) | |
Construct from Istream. More... | |
PackedBoolList (const label size) | |
Construct with given size, initializes 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 Xfer< PackedBoolList > &) | |
Construct by transferring the parameter contents. More... | |
PackedBoolList (const Xfer< PackedList< 1 > > &) | |
Construct by transferring the parameter contents. 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< PackedBoolList > | clone () 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... | |
Xfer< 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... | |
Xfer< PackedBoolList > | xfer () |
Transfer contents to the Xfer container. More... | |
PackedBoolList & | operator= (const bool val) |
Assignment of all entries to the given value. More... | |
PackedBoolList & | operator= (const PackedBoolList &) |
Assignment operator. More... | |
PackedBoolList & | operator= (const PackedList< 1 > &) |
Assignment operator. More... | |
PackedBoolList & | operator= (const Foam::UList< bool > &) |
Assignment operator. More... | |
PackedBoolList & | operator= (const labelUList &indices) |
Assignment operator,. More... | |
PackedBoolList & | operator= (const UIndirectList< label > &) |
Assignment operator,. More... | |
PackedBoolList | operator~ () const |
Complement operator. More... | |
PackedBoolList & | operator&= (const PackedList< 1 > &) |
And operator (lists may be dissimilar sizes) More... | |
PackedBoolList & | operator&= (const labelUList &indices) |
And operator (lists may be dissimilar sizes) More... | |
PackedBoolList & | operator&= (const UIndirectList< label > &) |
And operator (lists may be dissimilar sizes) More... | |
PackedBoolList & | operator^= (const PackedList< 1 > &) |
Xor operator (lists may be dissimilar sizes) More... | |
PackedBoolList & | operator|= (const PackedList< 1 > &) |
Or operator (lists may be dissimilar sizes) More... | |
PackedBoolList & | operator|= (const labelUList &indices) |
Or operator (lists may be dissimilar sizes),. More... | |
PackedBoolList & | operator|= (const UIndirectList< label > &) |
Or operator (lists may be dissimilar sizes),. More... | |
PackedBoolList & | operator+= (const PackedList< 1 > &) |
Add entries to this list, synonymous with the or operator. More... | |
PackedBoolList & | operator+= (const labelUList &indices) |
Add entries to this list, synonymous with the or operator. More... | |
PackedBoolList & | operator+= (const UIndirectList< label > &) |
Add entries to this list, synonymous with the or operator. More... | |
PackedBoolList & | operator-= (const PackedList< 1 > &) |
Remove entries from this list - unset the specified bits. More... | |
PackedBoolList & | operator-= (const labelUList &indices) |
Remove entries from this list - unset the specified bits. More... | |
PackedBoolList & | operator-= (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) |
![]() | |
label | packedLength () const |
The list length when packed. More... | |
PackedList () | |
Null constructor. More... | |
PackedList (const label size) | |
Construct with given size, initializes 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 (const Xfer< PackedList< nBits > > &) | |
Construct by transferring the parameter contents. 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... | |
Xfer< labelList > | values () const |
Return the values as a list of labels. More... | |
Ostream & | printBits (Ostream &, const bool fullOutput=false) const |
Print bit patterns, optionally output unused elements. More... | |
Ostream & | printInfo (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... | |
Xfer< PackedList< nBits > > | xfer () |
Transfer contents to the Xfer container. More... | |
Istream & | read (Istream &) |
Clear list and read from stream. More... | |
Ostream & | write (Ostream &, const bool indexedOutput=false) const |
Write, optionally with indexedOutput. More... | |
void | writeEntry (Ostream &) const |
Write as a dictionary entry. More... | |
void | writeEntry (const word &keyword, Ostream &) const |
Write as a dictionary entry with keyword. 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... | |
PackedList< nBits > & | operator= (const unsigned int val) |
Assignment of all entries to the given value. Takes linear time. More... | |
PackedList< nBits > & | operator= (const PackedList< nBits > &) |
Assignment operator. More... | |
PackedList< nBits > & | operator= (const labelUList &) |
Assignment operator. More... | |
PackedList< nBits > & | 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... | |
Private Member Functions | |
bool | bitorPrepare (const PackedList< 1 > &lst, label &maxPackLen) |
Preparation, resizing before a bitor operation. More... | |
template<class LabelListType > | |
label | setIndices (const LabelListType &indices) |
Set the listed indices. Return number of elements changed. More... | |
template<class LabelListType > | |
label | unsetIndices (const LabelListType &indices) |
Unset the listed indices. Return number of elements changed. More... | |
template<class LabelListType > | |
label | subsetIndices (const LabelListType &indices) |
Subset with the listed indices. Return number of elements subsetted. More... | |
Additional Inherited Members | |
![]() | |
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... | |
![]() | |
typedef unsigned int | StorageType |
typedef List< StorageType > | StorageList |
![]() | |
unsigned int | readValue (Istream &is) |
void | setPair (Istream &) |
Read an index/value pair and set accordingly. More... | |
void | setPair (Istream &is) |
![]() | |
static label | packedLength (const label) |
Calculate the list length when packed. More... | |
static unsigned int | readValue (Istream &) |
Read a list entry (allows for specialization) More... | |
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.
Definition at line 63 of file PackedBoolList.H.
|
inline |
Construct null.
Definition at line 28 of file PackedBoolListI.H.
PackedBoolList | ( | Istream & | is | ) |
Construct from Istream.
Definition at line 159 of file PackedBoolList.C.
|
inlineexplicit |
Construct with given size, initializes list to 0.
Definition at line 34 of file PackedBoolListI.H.
|
inline |
Construct with given size and value for all elements.
Definition at line 41 of file PackedBoolListI.H.
|
inline |
Copy constructor.
Definition at line 50 of file PackedBoolListI.H.
|
inlineexplicit |
Copy constructor.
Definition at line 56 of file PackedBoolListI.H.
|
inline |
Construct by transferring the parameter contents.
Definition at line 62 of file PackedBoolListI.H.
References PackedBoolList::transfer().
|
inline |
Construct by transferring the parameter contents.
Definition at line 70 of file PackedBoolListI.H.
|
inlineexplicit |
Construct from a list of bools.
Definition at line 76 of file PackedBoolListI.H.
References PackedBoolList::operator=().
|
inlineexplicit |
Construct from a list of labels.
using the labels as indices to indicate which bits are set
Definition at line 84 of file PackedBoolListI.H.
References PackedBoolList::set().
|
inlineexplicit |
Construct from a list of labels.
using the labels as indices to indicate which bits are set
Definition at line 92 of file PackedBoolListI.H.
References PackedBoolList::set().
|
private |
Preparation, resizing before a bitor operation.
returns true if the later result needs trimming
Definition at line 32 of file PackedBoolList.C.
References PackedList::packedLength(), resize(), PackedList::size(), and PackedList::storage().
|
private |
Set the listed indices. Return number of elements changed.
Does auto-vivify for non-existent entries.
|
private |
Unset the listed indices. Return number of elements changed.
Never auto-vivify entries.
|
private |
Subset with the listed indices. Return number of elements subsetted.
|
inline |
Clone.
Definition at line 101 of file PackedBoolListI.H.
void set | ( | const PackedList< 1 > & | lst | ) |
Set specified bits.
Definition at line 169 of file PackedBoolList.C.
References PackedList::storage(), and Foam::stringOps::trim().
Referenced by PatchTools::calcBounds(), isoSurfaceCell::calcSnappedPoint(), dynamicRefineFvMesh::calculateProtectedCells(), dynamicRefineFvMesh::checkEightAnchorPoints(), hexRef8::consistentUnrefinement(), AABBTree::createBoxes(), dynamicRefineFvMesh::dynamicRefineFvMesh(), dynamicRefineFvMesh::extendMarkedCells(), motionSmootherAlgo::getAffectedFacesAndPoints(), meshRefinement::getChangedFaces(), autoSnapDriver::getCollocatedPoints(), meshRefinement::intersectedPoints(), isoSurface::isoSurface(), isoSurfaceCell::isoSurfaceCell(), main(), meshRefinement::markFacesOnProblemCells(), meshRefinement::markFeatureCellLevel(), PackedBoolList::PackedBoolList(), NASedgeFormat::read(), STARCDedgeFormat::read(), dynamicRefineFvMesh::refine(), autoSnapDriver::repatchToSurface(), dynamicRefineFvMesh::selectRefineCandidates(), motionSmootherAlgo::setDisplacement(), PackedBoolList::setIndices(), hexRef8::setRefinement(), fieldSmoother::smoothNormals(), triSurface::stitchTriangles(), PackedBoolList::subsetIndices(), dynamicRefineFvMesh::unrefine(), dynamicRefineFvMesh::update(), and triSurface::writeStats().
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.
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.
void unset | ( | const PackedList< 1 > & | lst | ) |
Unset specified bits.
Definition at line 203 of file PackedBoolList.C.
References Foam::min(), PackedList::packedLength(), and PackedList::storage().
Referenced by hexRef8::consistentUnrefinement(), syncTools::getInternalOrCoupledFaces(), syncTools::getInternalOrMasterFaces(), syncTools::getMasterFaces(), hexRef8::setRefinement(), and autoSnapDriver::smoothPatchDisplacement().
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.
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.
void subset | ( | const PackedList< 1 > & | lst | ) |
Subset with the specified list.
Definition at line 231 of file PackedBoolList.C.
References resize(), PackedList::size(), and PackedList::storage().
Foam::label subset | ( | const labelUList & | indices | ) |
Subset with the listed indices.
Return number of elements subsetted.
Definition at line 252 of file PackedBoolList.C.
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.
Foam::Xfer< 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 forAll, List::setSize(), List::size(), and List::xfer().
Referenced by main(), and sampledPlane::update().
|
inline |
Transfer the contents of the argument list into this list.
and annul the argument list.
Definition at line 109 of file PackedBoolListI.H.
References PackedList::transfer().
Referenced by PackedBoolList::PackedBoolList().
|
inline |
Transfer the contents of the argument list into this list.
and annul the argument list.
Definition at line 115 of file PackedBoolListI.H.
References PackedList::transfer().
|
inline |
Transfer contents to the Xfer container.
Definition at line 121 of file PackedBoolListI.H.
References Foam::xferMove().
|
inline |
Assignment of all entries to the given value.
Definition at line 130 of file PackedBoolListI.H.
References PackedList::operator=().
Referenced by PackedBoolList::PackedBoolList().
|
inline |
Assignment operator.
Definition at line 138 of file PackedBoolListI.H.
References PackedList::operator=().
|
inline |
Assignment operator.
Definition at line 146 of file PackedBoolListI.H.
References PackedList::operator=().
Foam::PackedBoolList & operator= | ( | const Foam::UList< bool > & | lst | ) |
Assignment operator.
Definition at line 290 of file PackedBoolList.C.
References forAll, setSize(), and UList::size().
|
inline |
Assignment operator,.
using the labels as indices to indicate which bits are set
Definition at line 154 of file PackedBoolListI.H.
References clear().
|
inline |
Assignment operator,.
using the labels as indices to indicate which bits are set
Definition at line 164 of file PackedBoolListI.H.
References clear().
|
inline |
Complement operator.
Definition at line 174 of file PackedBoolListI.H.
References PackedList::flip().
|
inline |
And operator (lists may be dissimilar sizes)
Definition at line 184 of file PackedBoolListI.H.
References Foam::subset().
|
inline |
And 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.
References Foam::subset().
|
inline |
And operator (lists may be dissimilar sizes)
using the labels as indices to indicate which bits are set
Definition at line 200 of file PackedBoolListI.H.
References Foam::subset().
Foam::PackedBoolList & operator^= | ( | const PackedList< 1 > & | lst | ) |
Xor operator (lists may be dissimilar sizes)
Retains unique entries
Definition at line 305 of file PackedBoolList.C.
References PackedList::storage(), and Foam::stringOps::trim().
|
inline |
Or operator (lists may be dissimilar sizes)
Definition at line 208 of file PackedBoolListI.H.
|
inline |
Or operator (lists may be dissimilar sizes),.
using the labels as indices to indicate which bits are set
Definition at line 216 of file PackedBoolListI.H.
|
inline |
Or operator (lists may be dissimilar sizes),.
using the labels as indices to indicate which bits are set
Definition at line 224 of file PackedBoolListI.H.
|
inline |
Add entries to this list, synonymous with the or operator.
Definition at line 232 of file PackedBoolListI.H.
|
inline |
Add entries to this list, synonymous with the or operator.
Definition at line 239 of file PackedBoolListI.H.
|
inline |
Add entries to this list, synonymous with the or operator.
Definition at line 246 of file PackedBoolListI.H.
|
inline |
Remove entries from this list - unset the specified bits.
Definition at line 253 of file PackedBoolListI.H.
|
inline |
Remove entries from this list - unset the specified bits.
Definition at line 261 of file PackedBoolListI.H.
|
inline |
Remove entries from this list - unset the specified bits.
Definition at line 269 of file PackedBoolListI.H.
Foam::label setIndices | ( | const LabelListType & | indices | ) |
Definition at line 93 of file PackedBoolList.C.
References forAll, PackedList< 1 >::reserve(), and PackedBoolList::set().
Foam::label unsetIndices | ( | const LabelListType & | indices | ) |
Definition at line 112 of file PackedBoolList.C.
References forAll.
Foam::label subsetIndices | ( | const LabelListType & | indices | ) |
Definition at line 128 of file PackedBoolList.C.
References clear(), forAll, PackedList::reserve(), and PackedBoolList::set().
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.