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