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)
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;
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 nElem, const
unsigned int val = 0u);
366 inline
void reserve(const label nElem);
390 inline std::streamsize
byteSize() const;
425 inline
unsigned int remove();
429 inline
unsigned int operator[](const label i) const;
433 inline reference
operator[](const label i);
442 inline
void operator=(const
unsigned int val);
466 inline unsigned int get()
const;
469 inline bool set(
unsigned int val);
483 inline void operator=(
const unsigned int val);
486 inline operator unsigned int ()
const;
498 friend Ostream& operator<< <Width>
504 friend Istream&
operator>> <Width>
515 void assign(
const unsigned int val) { this->
fill(val); }
522 void setSize(
const label len,
unsigned int val = 0u)
533 template<
unsigned W
idth>
541 template<
unsigned W
idth>
542 inline bool operator==(
const PackedList<Width>& a,
const PackedList<Width>&
b);
545 template<
unsigned W
idth>
546 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.
void setSize(const label len, unsigned int val=0u)
Alias for resize()
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.
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.
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)
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.
label capacity() const
The number of elements that can be stored with reallocating.
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>...
void operator=(const PackedList< Width > &lst)
Copy assignment.
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.
void copyAssign(const PackedList< Width > &rhs)
Copy assignment.
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)