92#ifndef Foam_PackedList_H
93#define Foam_PackedList_H
101#include <type_traits>
109template<
unsigned W
idth>
class PackedList;
112template<
unsigned W
idth>
115template<
unsigned W
idth>
118template<
unsigned W
idth>
126template<
unsigned W
idth>
142 = (std::numeric_limits<block_type>::digits);
164 static constexpr label
num_blocks(label numElem)
noexcept
198 "Width must be > 0 and minimum of two items per data block"
239 inline explicit
PackedList(const label numElem);
243 inline
PackedList(const label numElem, const
unsigned int val);
306 inline
unsigned int get(const label i) const;
311 inline
bool set(const label i,
unsigned int val = ~0u);
316 inline
bool unset(const label i);
323 template<class IntType =
unsigned int>
328 template<class IntType =
unsigned int>
334 template<class IntType =
unsigned int>
341 inline
void fill(const
unsigned int val);
347 inline
bool trim(label minpos = -1);
360 inline
void resize(const label numElem, const
unsigned int val = 0u);
368 inline
void reserve(const label numElem);
443 inline
unsigned int remove();
447 inline
unsigned int operator[](const label i) const;
460 inline
void operator=(const
unsigned int val);
484 inline unsigned int get()
const;
487 inline bool set(
unsigned int val);
501 inline void operator=(
const unsigned int val);
504 inline operator unsigned int ()
const;
516 friend Ostream& operator<< <Width>
522 friend Istream&
operator>> <Width>
551 void assign(
const unsigned int val) { this->
fill(val); }
565template<
unsigned W
idth>
573template<
unsigned W
idth>
581template<
unsigned W
idth>
582inline bool operator==(
const PackedList<Width>& a,
const PackedList<Width>&
b);
585template<
unsigned W
idth>
586inline bool operator!=(
const PackedList<Width>& a,
const PackedList<Width>&
b);
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
A helper class for outputting values to Ostream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
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 reference supporting read/write access to an entry.
reference(PackedList *parent, const label index)
unsigned shift_
The bit shift to access the given sub-portion.
block_type & ref_
Reference to the block.
reference(const reference &)=default
Copy construct.
reference(reference &&)=default
Move construct.
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
void copyAssign(const PackedList< Width > &rhs)
Copy assignment.
unsigned int const_reference
void shrink()
Shrink the allocated space to what is actually used.
label size_
Number of entries used.
static unsigned int readValue(Istream &is)
Read a list entry (allows for specialization)
void swap(PackedList< Width > &rhs)
Swap contents with argument.
bool unset(const label i)
Unset the entry at index i.
char * data_bytes() noexcept
A pointer to the raw storage, reinterpreted as byte data.
void checkIndex(const label i) const
Check index is within valid range [0,size)
const unsigned int * cdata() const noexcept
A const pointer to the raw storage.
List< block_type > block_container
The internal container for storing the blocks.
bool equal(const PackedList< Width > &other) const
Test for equality of sizes and the bits set.
static constexpr block_type mask_lower(unsigned elementOffset)
Masking for all bits below the element offset.
block_container blocks_
The blocks of raw data.
bool empty() const noexcept
True if the list is empty (ie, size() is zero).
labelList values() const
Return the values as a list of labels.
void resize_nocopy(const label numElem)
Currently identical to resize. Subject to future change (Oct-2021)
void setSize(const label n, unsigned int val=0u)
Alias for resize()
autoPtr< PackedList< Width > > clone() const
Clone.
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
void fill(const unsigned int val)
Assign all entries to the given value.
void assign(const unsigned int val)
Deprecated(2020-11) use fill()
List< IntType > unpack() const
Return the values as a list of integral type.
static constexpr block_type max_value
static unsigned int repeated_value(unsigned val)
A fill value for complete blocks.
void setCapacity(const label numElem)
Alter the size of the underlying storage.
void clear_trailing_bits()
Clear any partial rubbish in the last addressable block.
static constexpr unsigned element_width
The width of an individual element (in bits).
std::streamsize byteSize() const noexcept
InfoProxy< PackedList< Width > > info() const
Return info proxy.
label nBlocks() const
The number of internal storage blocks.
Ostream & printBits(Ostream &os, bool debugOutput=false) const
Print bit patterns, optionally with extra debug.
void clearStorage()
Clear the list and delete storage.
label capacity() const noexcept
The number of elements that can be stored with reallocating.
label size() const noexcept
Number of entries.
bool set(const label i, unsigned int val=~0u)
Set value at index i, default value set is the max_value.
bool trim(label minpos=-1)
friend Ostream & operator(Ostream &os, const InfoProxy< PackedList< Width > > &info)
void reserve(const label numElem)
unsigned int get(const label i) const
Get value at index i or 0 for out-of-range.
void operator=(const PackedList< Width > &lst)
Copy assignment.
constexpr PackedList() noexcept
Default construct, zero-sized and no allocation.
PackedList< Width > & append(const unsigned int val)
Append a value at the end of the list.
static constexpr unsigned elem_per_block
The number of elements stored per data block.
void transfer(PackedList< Width > &rhs)
const char * cdata_bytes() const noexcept
A const pointer to the raw storage, reinterpreted as byte data.
void writeEntry(Ostream &os) const
Write as a dictionary entry.
const List< unsigned int > & storage() const
Return the underlying storage blocks.
static constexpr label num_blocks(label numElem) noexcept
void setPair(Istream &is)
Read an index/value pair and set accordingly.
unsigned int block_type
The storage block type for bit elements.
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
void clear()
Clear the list, i.e. set addressable size to zero.
Istream & readList(Istream &is)
Clear list and read from stream.
void reset()
Clear all bits but do not adjust the addressable size.
std::streamsize size_bytes() const noexcept
static constexpr unsigned bits_per_block
The number of bits in a single block.
unsigned int remove()
Remove and return the last element.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Database for solution data, solver performance and other reduced data.
A range or interval of labels defined by a start and a size.
A class for handling words, derived from Foam::string.
OBJstream os(runTime.globalPath()/outputName)
bool operator!=(const eddy &a, const eddy &b)
unsigned Hasher(const void *data, size_t len, unsigned seed=0)
Bob Jenkins's 96-bit mixer hashing function (lookup3)
tmp< GeometricField< Type, fvPatchField, volMesh > > operator&(const fvMatrix< Type > &, const DimensionedField< Type, volMesh > &)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Istream & operator>>(Istream &, directionInfo &)
Number of items before requiring line-breaks in the list output.
Template-invariant parts for PackedList.
Hash function class. The default definition is for primitives. Non-primitives used to hash entries on...
Hashing functor for PackedList.
unsigned operator()(const PackedList< Width > &obj) const