Go to the documentation of this file.
101 #include <type_traits>
115 template<
unsigned W
idth>
118 template<
unsigned W
idth>
121 template<
unsigned W
idth>
129 template<
unsigned W
idth>
143 = (std::numeric_limits<block_type>::digits);
165 static constexpr label
num_blocks(label numElem)
199 "Width must be > 0 and minimum of two items per data block"
237 inline explicit
PackedList(const label numElem);
241 inline
PackedList(const label numElem, const
unsigned int val);
285 inline label
size() const noexcept;
288 inline
bool empty() const noexcept;
304 inline
unsigned int get(const label i) const;
309 inline
bool set(const label i,
unsigned int val = ~0u);
314 inline
bool unset(const label i);
321 template<class IntType =
unsigned int>
326 template<class IntType =
unsigned int>
332 template<class IntType =
unsigned int>
339 inline
void assign(const
unsigned int val);
348 inline
bool trim(label minpos=-1);
360 inline
void resize(const label nElem, const
unsigned int val = 0u);
363 inline
void setSize(const label nElem, const
unsigned int val = 0u);
369 inline
void reserve(const label nElem);
393 inline std::streamsize
byteSize() const;
428 inline
unsigned int remove();
432 inline
unsigned int operator[](const label i) const;
436 inline reference
operator[](const label i);
439 inline
void operator=(const
unsigned int val);
469 inline unsigned int get()
const;
472 inline bool set(
unsigned int val);
486 inline void operator=(
const unsigned int val);
489 inline operator unsigned int ()
const;
501 friend Ostream& operator<< <Width>
507 friend Istream&
operator>> <Width>
519 template<
unsigned W
idth>
527 template<
unsigned W
idth>
528 inline bool operator==(
const PackedList<Width>& a,
const PackedList<Width>&
b);
531 template<
unsigned W
idth>
532 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.
A class for handling words, derived from Foam::string.
A helper class for outputting values to Ostream.
block_type & ref_
Reference to the block.
tmp< GeometricField< Type, fvPatchField, volMesh > > operator&(const fvMatrix< Type > &, const DimensionedField< Type, volMesh > &)
friend Ostream & operator(Ostream &os, const InfoProxy< PackedList< Width >> &info)
Istream & read(Istream &is)
Clear list and read from stream.
A reference supporting read/write access to an entry.
autoPtr< PackedList< Width > > clone() const
Clone.
unsigned int block_type
The storage block type for bit elements.
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 & operator>>(Istream &, directionInfo &)
constexpr PackedList() noexcept
Default construct, zero-sized and no allocation.
void checkIndex(const label i) const
Check index is within valid range [0,size)
void resize(const label nElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated 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.
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.
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)....
void setCapacity(const label nElem)
Alter the size of the underlying storage.
void operator=(const unsigned int val)
Assignment of all entries to the given value. Takes linear time.
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.
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
static constexpr label num_blocks(label numElem)
std::streamsize byteSize() const
void transfer(PackedList< Width > &rhs)
Transfer the contents of the argument list into this list.
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)
Assign all entries to the given value. Takes linear time.
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.
label capacity() const
The number of elements that can be stored with reallocating.
void setSize(const label nElem, const unsigned int val=0u)
Alias for resize()
static constexpr unsigned elem_per_block
The number of elements stored per data block.
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
label size() const noexcept
Number of entries.
void reserve(const label nElem)
Reserve allocation space for at least this size.
bool trim(label minpos=-1)
const List< unsigned int > & storage() const
Return the underlying storage blocks.
Template-invariant parts for PackedList.
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....
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.
static constexpr unsigned bits_per_block
The number of bits in a single block.
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)