61 template<
class T>
class List;
167 template<
class UIntType>
172 for (;
x; ++
n) {
x &= (
x-1); }
182 x -= (
x >> 1) & 0x55555555;
183 x = (
x & 0x33333333) + ((
x >> 2) & 0x33333333);
185 return ((((
x + (
x >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24);
193 x -= (
x >> 1) & 0x5555555555555555;
194 x = (
x & 0x3333333333333333) + ((
x >> 2) & 0x3333333333333333);
197 ((((
x + (
x >> 4)) & 0x0F0F0F0F0F0F0F0F) * 0x0101010101010101) >> 56);
207 template<
class UIntType,
unsigned BitW
idth>
212 BitWidth && std::numeric_limits<UIntType>::digits >= BitWidth,
213 "BitWidth too large for target output" 217 const unsigned nrepeat = (std::numeric_limits<UIntType>::digits / BitWidth);
220 const unsigned mask = ((1u << BitWidth) - 1);
223 UIntType fillval = ((val >= mask) ? mask : val);
226 for (
unsigned i = 1; i < nrepeat; ++i)
228 fillval |= (fillval << BitWidth);
236 template<
class UIntType>
237 inline Ostream&
print(Ostream&
os, UIntType value,
char off=
'0',
char on=
'1')
249 unsigned test = (1u << (std::numeric_limits<UIntType>::digits-1));
254 os << ((value & test) ? on : off);
263 template<
class UIntType>
276 operator UIntType ()
const {
return value; }
279 operator UIntType& () {
return value; }
355 template<
class UIntType>
356 inline Ostream& operator<<(Ostream& os, const BitOps::bitInfo<UIntType>& info)
UIntType repeat_value(unsigned val)
Repeat a value of the given BitWidth into the destination output type.
bool any(const UList< bool > &bools)
True if any entries are 'true'.
bool none(const UList< bool > &bools)
True if no entries are 'true'.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Ostream & print(Ostream &os, UIntType value, char off='0', char on='1')
Print 0/1 bits in the (unsigned) integral type.
List< bool > select(const labelUList &locations)
Construct an auto-sized selection list of bools (all false), and populate the specified locations as ...
A range or interval of labels defined by a start and a size.
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< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
constexpr bitInfo() noexcept
Null constructible as zero.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
A functor that returns its argument unchanged (cf. C++20 std::identity) Should never be specialized...
List< bool > bools(const labelHashSet &locations)
Transform the on locations to a boolList, with true for each non-negative location and false for all ...
OBJstream os(runTime.globalPath()/outputName)
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
unsigned int bit_count(UIntType x)
Count arbitrary number of bits (of an integral type)
bool all(const UList< bool > &bools)
True if all entries are 'true' or if the set is empty.
List< label > sortedToc(const UList< bool > &bools)
Return the (sorted) values corresponding to 'true' entries.
iterator end() noexcept
Return an iterator to end traversing the UList.
bitSet create(const label n, const labelHashSet &locations, const bool on=true)
Create a bitSet with length n with the specified on locations.
List< label > toc(const UList< bool > &bools)
Return the (sorted) values corresponding to 'true' entries.
bitSet bitset(const labelHashSet &locations)
Transform the on locations to a bitSet.