61template<
class T>
class List;
77 return std::count(bools.
begin(), bools.
end(), val);
145unsigned int count(
const bitSet& bitset,
const bool on=
true);
184template<
class UIntType>
189 for (;
x; ++
n) {
x &= (
x-1); }
199 x -= (
x >> 1) & 0x55555555;
200 x = (
x & 0x33333333) + ((
x >> 2) & 0x33333333);
202 return ((((
x + (
x >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24);
210 x -= (
x >> 1) & 0x5555555555555555;
211 x = (
x & 0x3333333333333333) + ((
x >> 2) & 0x3333333333333333);
214 ((((
x + (
x >> 4)) & 0x0F0F0F0F0F0F0F0F) * 0x0101010101010101) >> 56);
224template<
class UIntType,
unsigned BitW
idth>
229 BitWidth && std::numeric_limits<UIntType>::digits >= BitWidth,
230 "BitWidth too large for target output"
234 const unsigned nrepeat = (std::numeric_limits<UIntType>::digits / BitWidth);
237 const unsigned mask = ((1u << BitWidth) - 1);
240 UIntType fillval = ((val >= mask) ? mask : val);
243 for (
unsigned i = 1; i < nrepeat; ++i)
245 fillval |= (fillval << BitWidth);
253template<
class UIntType>
254inline Ostream&
print(Ostream&
os, UIntType value,
char off=
'0',
char on=
'1')
266 unsigned test = (1u << (std::numeric_limits<UIntType>::digits-1));
271 os << ((value & test) ? on : off);
280template<
class UIntType>
296 operator UIntType& ()
noexcept {
return value; }
372template<
class UIntType>
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool any() const
True if any entries are 'true'.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
bool none() const
True if no entries are 'true'.
iterator end() noexcept
Return an iterator to end traversing the UList.
bool all() const
True if all entries are 'true' or if the list is empty.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
A range or interval of labels defined by a start and a size.
OBJstream os(runTime.globalPath()/outputName)
Various bit-wise operations and adaptor methods for containers that are somewhat similar to bitSet (e...
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
List< bool > select(const label n, const labelUList &locations)
Construct a selection list of bools (all false) with the given pre-size, subsequently add specified l...
void unset(List< bool > &bools, const labelUList &locations)
Unset the listed locations (assign 'false').
List< label > toc(const UList< bool > &bools)
Return the (sorted) values corresponding to 'true' entries.
bool any(const UList< bool > &bools)
True if any entries are 'true'.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
bool all(const UList< bool > &bools)
True if all entries are 'true' or if the list is empty.
unsigned int bit_count(UIntType x)
Count arbitrary number of bits (of an integral type).
List< label > sortedToc(const UList< bool > &bools)
Return the (sorted) values corresponding to 'true' entries.
Ostream & print(Ostream &os, UIntType value, char off='0', char on='1')
Print 0/1 bits in the (unsigned) integral type.
bool none(const UList< bool > &bools)
True if no entries are 'true'.
UIntType repeat_value(unsigned val)
Repeat a value of the given BitWidth into the destination output type.
Factory and other methods for bitSet. Adaptor methods for other containers that are somewhat similar ...
bitSet create(const label n, const labelHashSet &locations, const bool on=true)
Create a bitSet with length n with the specified on locations.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
UList< label > labelUList
A UList of labels.
An (unsigned) integral type adapter, for output of bit values.
constexpr bitInfo() noexcept
Null constructible as zero.
bitInfo(UIntType val) noexcept
Value construct.