Foam::BitOps Namespace Reference

Various bit-wise operations, etc. More...

Classes

struct  bitInfo
 An (unsigned) integral type adapter, for output of bit values. More...
 

Functions

unsigned int count (const UList< bool > &bools, const bool val=true)
 Count number of 'true' entries. More...
 
bool all (const UList< bool > &bools)
 True if all entries are 'true' or if the set is empty. More...
 
bool any (const UList< bool > &bools)
 True if any entries are 'true'. More...
 
bool none (const UList< bool > &bools)
 True if no entries are 'true'. More...
 
template<class UIntType >
unsigned int bit_count (UIntType x)
 Count arbitrary number of bits (of an integral type) More...
 
template<>
unsigned int bit_count (uint32_t x)
 Count bits in a 32-bit value (Hamming weight method) More...
 
template<>
unsigned int bit_count (uint64_t x)
 Count bits in a 64-bit value (Hamming weight method) More...
 
template<class UIntType , unsigned BitWidth>
UIntType repeat_value (unsigned val)
 Repeat a value of the given BitWidth into the destination output type. More...
 
template<class UIntType >
Ostreamprint (Ostream &os, UIntType value, char off='0', char on='1')
 Print 0/1 bits in the (unsigned) integral type. More...
 

Detailed Description

Various bit-wise operations, etc.

The population count uses the Hamming weight (http://en.wikipedia.org/wiki/Hamming_weight).

Function Documentation

◆ count()

unsigned int Foam::BitOps::count ( const UList< bool > &  bools,
const bool  val = true 
)
inline

Count number of 'true' entries.

Parameters
valcan be set to false to count the number of false values instead For compatibility with bitSet::count()

Definition at line 74 of file BitOps.H.

Referenced by geometric::add(), triSurfaceMesh::addFaceToEdge(), IOobjectList::append(), CStringList::asList(), UOPstream::beginRawWrite(), MeshedSurface< Foam::face >::checkZones(), surfMesh::checkZones(), probes::classifyFields(), hexRef8::consistentSlowRefinement(), cellCellStencil::count(), objectRegistry::count(), IOobjectList::count(), HashTable< Foam::phase * >::countEntries(), IOobjectList::countImpl(), objectRegistry::countImpl(), HashTable< Foam::phase * >::countKeys(), IOobjectList::countTypeImpl(), objectRegistry::countTypeImpl(), HashTable< Foam::phase * >::countValues(), decompositionMethod::decompose(), snappyVoxelMeshDriver::doRefine(), Foam::duplicateOrder(), limitFields::execute(), NURBS3DVolume::findPointsInBox(), hashedWordList::hashedWordList(), Histogram< List >::Histogram(), Foam::indicesImpl(), ZoneMesh< cellZone, polyMesh >::indicesImpl(), InjectionModelList< Foam::KinematicCloud< Cloud< basicKinematicCollidingParcel > > >::InjectionModelList(), Foam::inplaceSubset(), Foam::inplaceSubsetList(), Foam::inplaceSubsetMatchingStrings(), wordRes::matching(), scalars::matching(), regionProperties::names(), Foam::namesImpl(), IOobjectList::namesImpl(), objectRegistry::namesImpl(), ZoneMesh< cellZone, polyMesh >::namesImpl(), IOobjectList::namesTypeImpl(), objectRegistry::namesTypeImpl(), UOprocess::newField(), polySurface::nFaceData(), blockMesh::numZonedBlocks(), refinementData::operator==(), ParticleForceList< KinematicCloud< Cloud< basicKinematicCollidingParcel > > >::ParticleForceList(), points_delaunay_naive_2d(), ParticleTracks< CloudType >::postFace(), Foam::printHostsSubscription(), HashTable< Foam::phase * >::printInfo(), FIRECore::putFireLabels(), ensightReadFile::read(), FixedValueConstraint< Type >::read(), ISstream::read(), UIPstream::read(), masterUncollatedFileOperation::readAndSend(), lumpedPointState::readPlain(), ISstream::readRaw(), UIPstream::readRaw(), FIREMeshReader::readSelections(), MRFZoneList::reset(), porosityModelList::reset(), optionAdjointList::reset(), optionList::reset(), SemiImplicitSource< Type >::setFieldData(), Foam::ListOps::setValue(), Foam::vtk::sizeofData(), ensightFaces::sizes(), ensightCells::sizes(), snappyVoxelMeshDriver::snappyVoxelMeshDriver(), regionProperties::sortedNames(), Foam::subsetMatchingStrings(), surfaceFeatures::surfaceFeatures(), Foam::system(), bitSet::toc(), HashTable< Foam::phase * >::toc(), HashTable< Foam::phase * >::tocEntries(), HashTable< Foam::phase * >::tocKeys(), HashTable< Foam::phase * >::tocValues(), wordRes::uniq(), hashedWordList::uniq(), Foam::uniqueOrder(), trackingInverseDistance::update(), cellVolumeWeight::update(), inverseDistance::update(), NamedEnum< EnumType, nEnum >::values(), NamedEnum< EnumType, nEnum >::words(), PtrListDetail< Foam::diameterModels::velocityGroup >::write(), prefixOSstream::write(), OSstream::write(), ensightFile::write(), UOPstream::write(), histogram::write(), Foam::writeAllAreaFields(), Foam::writeAllDimFields(), Foam::writeAllPointFields(), Foam::writeAllVolFields(), Foam::writeAreaFields(), Foam::ensightOutput::writeCloudField(), Foam::writeDimFields(), AMIMethod< SourcePatch, TargetPatch >::writeIntersectionOBJ(), Foam::meshTools::writeOBJ(), Foam::writePointFields(), OSstream::writeRaw(), UOPstream::writeRaw(), cellClassification::writeStats(), vtkWrite::writeVolFields(), ensightWrite::writeVolFields(), Foam::writeVolFields(), memorybuf::in::xsgetn(), and memorybuf::out::xsputn().

◆ all()

bool Foam::BitOps::all ( const UList< bool > &  bools)
inline

True if all entries are 'true' or if the set is empty.

For compatibility with bitSet::all()

Definition at line 81 of file BitOps.H.

Referenced by decompositionMethod::decompose().

Here is the caller graph for this function:

◆ any()

bool Foam::BitOps::any ( const UList< bool > &  bools)
inline

True if any entries are 'true'.

For compatibility with bitSet::any()

Definition at line 88 of file BitOps.H.

Referenced by bitSet::toc().

Here is the caller graph for this function:

◆ none()

bool Foam::BitOps::none ( const UList< bool > &  bools)
inline

True if no entries are 'true'.

For compatibility with bitSet::none()

Definition at line 95 of file BitOps.H.

◆ bit_count() [1/3]

unsigned int Foam::BitOps::bit_count ( UIntType  x)
inline

Count arbitrary number of bits (of an integral type)

Definition at line 103 of file BitOps.H.

References n, and x.

Referenced by bitSet::count().

Here is the caller graph for this function:

◆ bit_count() [2/3]

unsigned int Foam::BitOps::bit_count ( uint32_t  x)
inline

Count bits in a 32-bit value (Hamming weight method)

Definition at line 115 of file BitOps.H.

References x.

◆ bit_count() [3/3]

unsigned int Foam::BitOps::bit_count ( uint64_t  x)
inline

Count bits in a 64-bit value (Hamming weight method)

Definition at line 126 of file BitOps.H.

References x.

◆ repeat_value()

UIntType Foam::BitOps::repeat_value ( unsigned  val)
inline

Repeat a value of the given BitWidth into the destination output type.

Note
when BitWidth is 1, it is better to do directly.
(val ? ~0u : 0u)

Definition at line 143 of file BitOps.H.

References Foam::val.

◆ print()

Ostream& Foam::BitOps::print ( Ostream os,
UIntType  value,
char  off = '0',
char  on = '1' 
)
inline

Print 0/1 bits in the (unsigned) integral type.

Definition at line 172 of file BitOps.H.

References IOstreamOption::BINARY, and IOstreamOption::format().

Referenced by if(), Foam::operator<<(), sampledDiscreteSurface::print(), dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::print(), indexedOctree< Foam::treeDataFace >::print(), PackedList< 2 >::printBits(), sampledPlane::update(), sampledPatch::update(), and seriesWriter::write().

Here is the call graph for this function:
Here is the caller graph for this function:
Foam::val
label ListType::const_reference val
Definition: ListOps.H:407