Loading...
Searching...
No Matches
PackedList< Width > Class Template Reference

A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width> template parameter. More...

#include <PackedList.H>

Inheritance diagram for PackedList< Width >:
Collaboration diagram for PackedList< Width >:

Classes

class  reference
 A reference supporting read/write access to an entry. More...
struct  hasher
 Hashing functor for PackedList. More...

Public Types

typedef unsigned int block_type
 The storage block type for bit elements.
typedef unsigned int const_reference

Public Member Functions

constexpr PackedList () noexcept
 Default construct, zero-sized and no allocation.
 PackedList (const label numElem)
 Construct for given number of elements, initializes values to 0.
 PackedList (const label numElem, const unsigned int val)
 Construct for given number of elements, and the specified value for each element.
 PackedList (Istream &is)
 Construct from Istream.
 PackedList (const PackedList< Width > &list)
 Copy construct.
 PackedList (PackedList< Width > &&list)
 Move construct.
 PackedList (const PackedList< Width > &list, const labelUList &addr)
 Copy construct a subset.
template<class Addr>
 PackedList (const PackedList< Width > &list, const IndirectListBase< label, Addr > &addr)
 Copy construct a subset.
 PackedList (const PackedList< Width > &list, const labelRange &range)
 Copy construct a subset range.
 PackedList (const labelUList &values)
 Construct from a list of values.
template<class Addr>
 PackedList (const IndirectListBase< label, Addr > &values)
 Construct from a indirect list of values.
autoPtr< PackedList< Width > > clone () const
 Clone.
void checkIndex (const label i) const
 Check index is within valid range [0,size).
bool empty () const noexcept
 True if the list is empty (ie, size() is zero).
label size () const noexcept
 Number of entries.
label capacity () const noexcept
 Number of elements that can be stored without reallocating.
bool uniform () const
 True if all entries have identical values (and list is non-empty).
bool equal (const PackedList< Width > &other) const
 Test for equality of sizes and the bits set.
unsigned int get (const label i) const
 Get value at index i or 0 for out-of-range.
bool set (const label i, unsigned int val=~0u)
 Set value at index i, default value set is the max_value.
bool unset (const label i)
 Unset the entry at index i.
labelList values () const
 Return the values as a list of labels.
template<class IntType = unsigned int>
List< IntType > unpack () const
 Return the values as a list of integral type.
template<class IntType = unsigned int>
List< IntType > unpack (const labelRange &range) const
 Return the range of values as a list of integral type.
template<class IntType = unsigned int>
List< IntType > unpack (const labelUList &locations) const
 Extract the values for the specified locations as a list of integral type.
void fill (const unsigned int val)
 Assign all entries to the given value.
bool trim (label minpos=-1)
 Trim any trailing zero elements, optionally specifying a a minimum position, below which trimming will not occur.
void reset ()
 Clear all bits but do not adjust the addressable size.
void setCapacity (const label numElem)
 Alter the size of the underlying storage.
void resize (const label numElem, const unsigned int val=0u)
 Reset addressable list size, does not shrink the allocated size.
void resize_nocopy (const label numElem)
 Currently identical to resize. Subject to future change (Oct-2021).
void reserve (const label numElem)
 Reserve allocation space for at least this size (uses a size doubling strategy).
void reserve_exact (const label numElem)
 Reserve allocation space for at least this size (uses the specified size without any other resizing strategy).
void clear ()
 Clear the list, i.e. set addressable size to zero.
void clearStorage ()
 Clear the list and delete storage.
void shrink_to_fit ()
 Shrink the allocated space to what is actually used.
void shrink ()
 Alias for shrink_to_fit().
void swap (PackedList< Width > &rhs)
 Swap contents with argument.
void transfer (PackedList< Width > &rhs)
 Transfer the contents of the argument list into this list and annul the argument list.
label num_blocks () const noexcept
 The number of internal storage blocks.
const List< block_type > & storage () const noexcept
 Return the underlying storage blocks.
List< block_type > & storage () noexcept
 Return the underlying storage blocks.
const block_typecdata () const noexcept
 A const pointer to the raw storage.
block_typedata () noexcept
 A pointer to the raw storage.
const char * cdata_bytes () const noexcept
 A const pointer to the raw storage, reinterpreted as byte data.
char * data_bytes () noexcept
 A pointer to the raw storage, reinterpreted as byte data.
std::streamsize size_data () const noexcept
 The number of integer blocks addressed in the raw storage. Same as num_blocks().
std::streamsize size_bytes () const noexcept
 The number of bytes addressed in the raw storage including any padding.
std::streamsize byteSize () const noexcept
 Same as size_bytes().
OstreamprintBits (Ostream &os, bool debugOutput=false) const
 Print bit patterns, optionally with extra debug.
IstreamreadList (Istream &is)
 Clear list and read from stream.
OstreamwriteList (Ostream &os, label shortLen=0) const
 Write List, with line-breaks in ASCII when length exceeds shortLen.
void writeEntry (const word &keyword, Ostream &os) const
 Write as a dictionary entry with keyword.
void push_back (const unsigned int val)
 Append a value at the end of the list.
void pop_back (label n=1)
 Reduce size by 1 or more elements. Can be called on an empty list.
unsigned int remove ()
 Remove and return the last element.
unsigned int operator[] (const label i) const
 Identical to get() - get value at index.
reference operator[] (const label i)
 Non-const access to value at index.
void operator= (const PackedList< Width > &list)
 Copy assignment.
void operator= (PackedList< Width > &&list)
 Move assignment.
void operator= (const unsigned int val)
 Assign all entries to the given value. fill().
InfoProxy< PackedList< Width > > info () const noexcept
 Return info proxy, used to print information to a stream.
void assign (const unsigned int val)
 Deprecated(2020-11) use fill().
void assign (const PackedList< Width > &rhs)
 Deprecated(2020-11) use operator=.
void setSize (const label n, unsigned int val=0u)
 Alias for resize().
PackedList< Width > & append (const unsigned int val)
 Append a value at the end of the list.
template<class IntType>
Foam::List< IntType > unpack () const
template<class IntType>
Foam::List< IntType > unpack (const labelRange &range) const
template<class IntType>
Foam::List< IntType > unpack (const labelUList &locations) const
Public Member Functions inherited from PackedListCore
 ClassNameNoDebug ("PackedList")
 Define template name.

Static Public Member Functions

static constexpr label num_blocks (label numElem) noexcept
 Calculate the number of blocks required to _address_ the requested number of elements.
static constexpr block_type mask_lower (unsigned elementOffset)
 Masking for all bits below the element offset.

Static Public Attributes

static constexpr unsigned bits_per_block = (std::numeric_limits<block_type>::digits)
 The number of bits in a single block.
static constexpr unsigned element_width = (Width)
 The width of an individual element (in bits).
static constexpr unsigned elem_per_block = (bits_per_block / Width)
 The number of elements stored per data block.
static constexpr block_type max_value = ((1u << Width) - 1)
 The max value for an element which is also the bit-mask of the individual element.

Protected Types

typedef List< block_typeblock_container
 The internal container for storing the blocks.

Protected Member Functions

void setPair (Istream &is)
 Read an index/value pair and set accordingly.
void writeEntry (Ostream &os) const
 Write as a dictionary entry.
void clear_trailing_bits ()
 Clear any partial rubbish in the last addressable block.
void copyAssign (const PackedList< Width > &rhs)
 Copy assignment.
label first_block () const
 Find the first block with a '1' bit.
label first_not_block () const
 Find the first block with a '0' bit.
unsigned int repeated_value (unsigned val)
unsigned int readValue (Istream &is)
void setPair (Istream &is)

Static Protected Member Functions

static unsigned int repeated_value (unsigned val)
 Enforce non-zero Width to fit within the block storage and require at least 2 items per storage block for general efficiency.
static unsigned int readValue (Istream &is)
 Read a list entry (allows for specialization).

Protected Attributes

block_container blocks_
 The blocks of raw data.
label size_
 Number of entries used.

Friends

Ostreamoperator<< (Ostream &os, const InfoProxy< PackedList< Width > > &info)
Istreamoperator>> (Istream &is, PackedList< Width > &list)

Detailed Description

template<unsigned Width>
class Foam::PackedList< Width >

A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width> template parameter.

Resizing is similar to DynamicList so that clear() and resize() affect the addressed size, but not the allocated size. The reserve() and setCapacity() methods can be used to influence the allocation.

Note
In a const context, the '[]' operator simply returns the stored value, with out-of-range elements returned as zero.

In a non-const context, the '[]' operator returns a reference to an existing value. When accessing out-of-range elements, some caution is required to ensure that the const version of the [] operator is actually being called. The get() method is functionally identical the the '[]' operator, but is always const access.

The set() and unset() methods return a bool if the value changed.

With const access, the get() method and 'operator[]' are identical. With non-const access, the 'operator[]' may be marginally slower get().

The set() method may be marginally faster than using the 'operator[]' supports auto-vivification and also returns a bool if the value changed, which can be useful for branching on changed values.

list.set(5, 4);
changed = list.set(5, 8);
if (changed) ...

In a const context, reading an out-of-range element returns zero without affecting the list size. For example,

list.resize(4);
Info<< list.get(10) << "\n"; // print zero, but doesn't adjust list
list.set(8); // auto-vivify
messageStream Info
Information stream (stdout output on master, null elsewhere).

Also note that all unused internal storage elements are guaranteed to always be bit-wise zero. This property must not be violated by any inheriting classes.

Note
Iterators for this class have been intentionally removed, for performance reasons.
See also
Foam::BitOps Foam::DynamicList
Source files

Definition at line 143 of file PackedList.H.

Member Typedef Documentation

◆ block_type

template<unsigned Width>
typedef unsigned int block_type

The storage block type for bit elements.

Note
Type name compatibility with boost::dynamic_bitset

Definition at line 156 of file PackedList.H.

◆ block_container

template<unsigned Width>
typedef List<block_type> block_container
protected

The internal container for storing the blocks.

Definition at line 219 of file PackedList.H.

◆ const_reference

template<unsigned Width>
typedef unsigned int const_reference

Definition at line 302 of file PackedList.H.

Constructor & Destructor Documentation

◆ PackedList() [1/11]

template<unsigned Width>
PackedList ( )
inlineconstexprnoexcept

Default construct, zero-sized and no allocation.

Definition at line 237 of file PackedListI.H.

References blocks_, Foam::noexcept, and size_.

Referenced by append(), assign(), copyAssign(), equal(), info(), PackedList< Width >::hasher::operator()(), operator<<, operator=(), operator=(), operator>>, PackedList(), PackedList(), PackedList(), PackedList(), readList(), swap(), transfer(), and writeList().

Here is the caller graph for this function:

◆ PackedList() [2/11]

template<unsigned Width>
PackedList ( const label numElem)
inlineexplicit

Construct for given number of elements, initializes values to 0.

Definition at line 245 of file PackedListI.H.

References blocks_, num_blocks(), and size_.

Here is the call graph for this function:

◆ PackedList() [3/11]

template<unsigned Width>
PackedList ( const label numElem,
const unsigned int val )
inline

Construct for given number of elements, and the specified value for each element.

Definition at line 253 of file PackedListI.H.

References blocks_, num_blocks(), operator=(), and size_.

Here is the call graph for this function:

◆ PackedList() [4/11]

template<unsigned Width>
PackedList ( Istream & is)
inline

Construct from Istream.

Definition at line 270 of file PackedListI.H.

References blocks_, and size_.

◆ PackedList() [5/11]

template<unsigned Width>
PackedList ( const PackedList< Width > & list)
inline

Copy construct.

Definition at line 280 of file PackedListI.H.

◆ PackedList() [6/11]

template<unsigned Width>
PackedList ( PackedList< Width > && list)
inline

Move construct.

Definition at line 288 of file PackedListI.H.

References blocks_, PackedList(), and size_.

Here is the call graph for this function:

◆ PackedList() [7/11]

template<unsigned Width>
PackedList ( const PackedList< Width > & list,
const labelUList & addr )

Copy construct a subset.

Definition at line 26 of file PackedList.C.

References get(), PackedList(), set(), size(), and UList< T >::size().

Here is the call graph for this function:

◆ PackedList() [8/11]

template<unsigned Width>
template<class Addr>
PackedList ( const PackedList< Width > & list,
const IndirectListBase< label, Addr > & addr )

Copy construct a subset.

Definition at line 45 of file PackedList.C.

References get(), PackedList(), set(), IndirectListBase< T, Addr >::size(), and size().

Here is the call graph for this function:

◆ PackedList() [9/11]

template<unsigned Width>
PackedList ( const PackedList< Width > & list,
const labelRange & range )

Copy construct a subset range.

Definition at line 63 of file PackedList.C.

References get(), PackedList(), Foam::pos(), range, set(), and size().

Here is the call graph for this function:

◆ PackedList() [10/11]

template<unsigned Width>
PackedList ( const labelUList & values)
inlineexplicit

Construct from a list of values.

Definition at line 298 of file PackedListI.H.

References blocks_, num_blocks(), size(), size_, and values().

Here is the call graph for this function:

◆ PackedList() [11/11]

template<unsigned Width>
template<class Addr>
PackedList ( const IndirectListBase< label, Addr > & values)
inlineexplicit

Construct from a indirect list of values.

Definition at line 318 of file PackedListI.H.

References blocks_, num_blocks(), set(), size(), size_, and values().

Here is the call graph for this function:

Member Function Documentation

◆ num_blocks() [1/2]

template<unsigned Width>
constexpr label num_blocks ( label numElem)
inlinestaticconstexprnoexcept

Calculate the number of blocks required to _address_ the requested number of elements.

We calculate this:

(numElem / elem_per_block)
+ (numElem % elem_per_block) ? 1 : 0
static constexpr unsigned elem_per_block
The number of elements stored per data block.
Definition PackedList.H:174

But avoiding the modulus operation

Definition at line 196 of file PackedList.H.

References elem_per_block.

Referenced by equal(), fill(), first_block(), first_not_block(), num_blocks(), PackedList(), PackedList(), PackedList(), PackedList(), printBits(), reserve_exact(), setCapacity(), size_bytes(), size_data(), trim(), and uniform().

Here is the caller graph for this function:

◆ mask_lower()

template<unsigned Width>
constexpr block_type mask_lower ( unsigned elementOffset)
inlinestaticconstexpr

Masking for all bits below the element offset.

Ill-defined when elementOffset is out of range.

Definition at line 206 of file PackedList.H.

References bits_per_block.

Referenced by clear_trailing_bits(), and first_not_block().

Here is the caller graph for this function:

◆ repeated_value() [1/2]

template<unsigned Width>
unsigned int repeated_value ( unsigned val)
inlinestaticprotected

Enforce non-zero Width to fit within the block storage and require at least 2 items per storage block for general efficiency.

Thus 1/2 of the base storage size is (sizeof(block_type)*8/2), or (sizeof(block_type) << 2)

A fill value for complete blocks

Definition at line 27 of file PackedListI.H.

References Foam::BitOps::repeat_value().

Referenced by fill(), and uniform().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readValue() [1/2]

template<unsigned Width>
unsigned int readValue ( Istream & is)
inlinestaticprotected

Read a list entry (allows for specialization).

Definition at line 34 of file PackedListI.H.

References Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, max_value, and Foam::readLabel().

Referenced by readList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPair() [1/2]

template<unsigned Width>
void setPair ( Istream & is)
inlineprotected

Read an index/value pair and set accordingly.

For bool specialization, read a single index value

Definition at line 51 of file PackedListI.H.

References IOstream::check(), Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, FUNCTION_NAME, max_value, Istream::readBegin(), Istream::readEnd(), Foam::readLabel(), and set().

Referenced by readList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeEntry() [1/2]

template<unsigned Width>
void writeEntry ( Ostream & os) const
protected

Write as a dictionary entry.

Definition at line 27 of file PackedListIO.C.

References os().

Here is the call graph for this function:

◆ clear_trailing_bits()

template<unsigned Width>
void clear_trailing_bits ( )
inlineprotected

Clear any partial rubbish in the last addressable block.

This rubbish may have arisen from block-wise operations etc.

Definition at line 76 of file PackedListI.H.

References blocks_, elem_per_block, mask_lower(), and size().

Referenced by fill().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyAssign()

template<unsigned Width>
void copyAssign ( const PackedList< Width > & rhs)
inlineprotected

Copy assignment.

Definition at line 135 of file PackedListI.H.

References blocks_, PackedList(), Foam::rhs(), and size_.

Referenced by operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ first_block()

template<unsigned Width>
Foam::label first_block ( ) const
inlineprotected

Find the first block with a '1' bit.

Returns
block number or -1 for an list or if all bits are OFF.

Definition at line 144 of file PackedListI.H.

References blocks_, num_blocks(), and size().

Referenced by uniform().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ first_not_block()

template<unsigned Width>
Foam::label first_not_block ( ) const
inlineprotected

Find the first block with a '0' bit.

Returns
block number or -1 for an list or if all bits are ON.

Definition at line 164 of file PackedListI.H.

References blocks_, elem_per_block, mask_lower(), num_blocks(), and size().

Referenced by uniform().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clone()

template<unsigned Width>
Foam::autoPtr< Foam::PackedList< Width > > clone ( ) const
inline

Clone.

Definition at line 341 of file PackedListI.H.

References Foam::New().

Here is the call graph for this function:

◆ checkIndex()

template<unsigned Width>
void checkIndex ( const label i) const
inline

Check index is within valid range [0,size).

Definition at line 419 of file PackedListI.H.

References FatalErrorInFunction, and size_.

Referenced by operator[]().

Here is the caller graph for this function:

◆ empty()

template<unsigned Width>
bool empty ( ) const
inlinenoexcept

True if the list is empty (ie, size() is zero).

Definition at line 387 of file PackedList.H.

References empty(), Foam::noexcept, and size_.

Referenced by ensightMesh::correct(), PatchTools::edgeNormals(), PatchTools::edgeNormals(), empty(), fill(), addPatchCellLayer::globalEdgeFaces(), PatchTools::pointNormals(), PatchTools::pointNormals(), trim(), and uniform().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

◆ capacity()

template<unsigned Width>
Foam::label capacity ( ) const
inlinenoexcept

Number of elements that can be stored without reallocating.

Definition at line 437 of file PackedListI.H.

References blocks_, elem_per_block, and Foam::noexcept.

Referenced by Foam::operator<<().

Here is the caller graph for this function:

◆ uniform()

template<unsigned Width>
bool uniform ( ) const

True if all entries have identical values (and list is non-empty).

Definition at line 85 of file PackedList.C.

References blocks_, elem_per_block, empty(), first_block(), first_not_block(), get(), max_value, num_blocks(), repeated_value(), and size().

Referenced by writeList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ equal()

template<unsigned Width>
bool equal ( const PackedList< Width > & other) const

Test for equality of sizes and the bits set.

Definition at line 147 of file PackedList.C.

References blocks_, num_blocks(), PackedList(), Foam::rhs(), and size().

Referenced by Foam::operator!=(), and Foam::operator==().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get()

template<unsigned Width>
unsigned int get ( const label i) const
inline

Get value at index i or 0 for out-of-range.

Never auto-vivify entries.

Definition at line 674 of file PackedListI.H.

Referenced by bitSet::bitSet(), bitSet::bitSet(), hexRef8::consistentUnrefinement(), operator[](), PackedList(), PackedList(), PackedList(), uniform(), and writeList().

Here is the caller graph for this function:

◆ set()

template<unsigned Width>
bool set ( const label i,
unsigned int val = ~0u )
inline

Set value at index i, default value set is the max_value.

Does auto-vivify for non-existent, non-zero entries.

Returns
true if value changed.

Definition at line 696 of file PackedListI.H.

References Foam::endl(), size(), size_, and WarningInFunction.

Referenced by PackedList(), PackedList(), PackedList(), PackedList(), readList(), setPair(), syncTools::syncFaceList(), bitSet::test_set(), and fileMonitor::updateStates().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unset()

template<unsigned Width>
bool unset ( const label i)
inline

Unset the entry at index i.

Never auto-vivify entries.

Returns
true if the value changed.

Definition at line 728 of file PackedListI.H.

References PackedList< Width >::reference::set(), and size().

Here is the call graph for this function:

◆ values()

template<unsigned Width>
Foam::labelList values ( ) const

Return the values as a list of labels.

Definition at line 170 of file PackedList.C.

References unpack().

Referenced by PackedList(), and PackedList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unpack() [1/6]

template<unsigned Width>
template<class IntType = unsigned int>
List< IntType > unpack ( ) const

Return the values as a list of integral type.

The default integral type is unsigned int.

References unpack().

Referenced by unpack(), unpack(), unpack(), and values().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unpack() [2/6]

template<unsigned Width>
template<class IntType = unsigned int>
List< IntType > unpack ( const labelRange & range) const

Return the range of values as a list of integral type.

The default integral type is unsigned int.

References range, and unpack().

Here is the call graph for this function:

◆ unpack() [3/6]

template<unsigned Width>
template<class IntType = unsigned int>
List< IntType > unpack ( const labelUList & locations) const

Extract the values for the specified locations as a list of integral type.

The default integral type is unsigned int.

References clear(), clearStorage(), fill(), reserve(), reserve_exact(), reset(), resize(), resize_nocopy(), setCapacity(), shrink_to_fit(), trim(), and unpack().

Here is the call graph for this function:

◆ fill()

template<unsigned Width>
void fill ( const unsigned int val)
inline

Assign all entries to the given value.

Definition at line 784 of file PackedListI.H.

References blocks_, clear_trailing_bits(), empty(), num_blocks(), repeated_value(), and size().

Referenced by assign(), operator=(), and unpack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ trim()

template<unsigned Width>
bool trim ( label minpos = -1)
inline

Trim any trailing zero elements, optionally specifying a a minimum position, below which trimming will not occur.

Returns
true if trimming changed the size.

Definition at line 90 of file PackedListI.H.

References blocks_, elem_per_block, empty(), num_blocks(), size(), and size_.

Referenced by Foam::reorder(), and unpack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

template<unsigned Width>
void reset ( )
inline

Clear all bits but do not adjust the addressable size.

Note
Method name compatibility with boost::dynamic_bitset

Definition at line 570 of file PackedListI.H.

References blocks_.

Referenced by Foam::calcElementMasks(), dynamicRefineFvMesh::calculateProtectedCells(), distanceSurface::filterRegionProximity(), dynamicMultiMotionSolverFvMesh::init(), multiSolidBodyMotionSolver::multiSolidBodyMotionSolver(), and unpack().

Here is the caller graph for this function:

◆ setCapacity()

template<unsigned Width>
void setCapacity ( const label numElem)
inline

Alter the size of the underlying storage.

The addressed size will be truncated if needed to fit, but will remain otherwise untouched.

Definition at line 517 of file PackedListI.H.

References blocks_, and num_blocks().

Referenced by unpack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resize()

◆ resize_nocopy()

template<unsigned Width>
void resize_nocopy ( const label numElem)
inline

Currently identical to resize. Subject to future change (Oct-2021).

Definition at line 444 of file PackedListI.H.

References resize().

Referenced by unpack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reserve()

template<unsigned Width>
void reserve ( const label numElem)
inline

Reserve allocation space for at least this size (uses a size doubling strategy).

Never shrinks the allocated size.

Definition at line 532 of file PackedListI.H.

References blocks_.

Referenced by Foam::reorder(), and unpack().

Here is the caller graph for this function:

◆ reserve_exact()

template<unsigned Width>
void reserve_exact ( const label numElem)
inline

Reserve allocation space for at least this size (uses the specified size without any other resizing strategy).

Never shrinks the allocated size.

Definition at line 551 of file PackedListI.H.

References blocks_, and num_blocks().

Referenced by unpack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

template<unsigned Width>
void clear ( )
inline

Clear the list, i.e. set addressable size to zero.

Does not adjust the underlying storage

Definition at line 577 of file PackedListI.H.

References reset(), and size_.

Referenced by dynamicRefineFvMesh::calculateProtectedCells(), readList(), bitSet::readListToc(), and unpack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearStorage()

template<unsigned Width>
void clearStorage ( )
inline

Clear the list and delete storage.

Definition at line 585 of file PackedListI.H.

References blocks_, and size_.

Referenced by ensightMesh::correct(), distanceSurface::createGeometry(), distanceSurface::filterKeepLargestRegion(), distanceSurface::filterKeepNearestRegions(), distanceSurface::filterRegionProximity(), and unpack().

Here is the caller graph for this function:

◆ shrink_to_fit()

template<unsigned Width>
void shrink_to_fit ( )
inline

Shrink the allocated space to what is actually used.

Definition at line 593 of file PackedListI.H.

Referenced by shrink(), and unpack().

Here is the caller graph for this function:

◆ shrink()

template<unsigned Width>
void shrink ( )
inline

Alias for shrink_to_fit().

Definition at line 545 of file PackedList.H.

References shrink(), and shrink_to_fit().

Referenced by shrink().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ swap()

template<unsigned Width>
void swap ( PackedList< Width > & rhs)
inline

Swap contents with argument.

Definition at line 647 of file PackedListI.H.

References PackedList(), and Foam::rhs().

Referenced by bitSet::swap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transfer()

template<unsigned Width>
void transfer ( PackedList< Width > & rhs)
inline

Transfer the contents of the argument list into this list and annul the argument list.

Definition at line 660 of file PackedListI.H.

References PackedList(), and Foam::rhs().

Referenced by operator=(), and bitSet::transfer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ num_blocks() [2/2]

template<unsigned Width>
Foam::label num_blocks ( ) const
inlinenoexcept

The number of internal storage blocks.

Definition at line 605 of file PackedListI.H.

References Foam::noexcept, num_blocks(), and size().

Here is the call graph for this function:

◆ storage() [1/2]

template<unsigned Width>
const List< block_type > & storage ( ) const
inlinenoexcept

Return the underlying storage blocks.

Definition at line 569 of file PackedList.H.

References blocks_, Foam::noexcept, and storage().

Referenced by storage(), and fileMonitor::updateStates().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ storage() [2/2]

template<unsigned Width>
List< block_type > & storage ( )
inlinenoexcept

Return the underlying storage blocks.

Manipulate with utmost caution

Definition at line 576 of file PackedList.H.

References blocks_, and Foam::noexcept.

◆ cdata()

template<unsigned Width>
const block_type * cdata ( ) const
inlinenoexcept

A const pointer to the raw storage.

Definition at line 581 of file PackedList.H.

References blocks_, and Foam::noexcept.

Referenced by PackedList< Width >::hasher::operator()().

Here is the caller graph for this function:

◆ data()

template<unsigned Width>
block_type * data ( )
inlinenoexcept

A pointer to the raw storage.

Definition at line 586 of file PackedList.H.

References blocks_, and Foam::noexcept.

◆ cdata_bytes()

template<unsigned Width>
const char * cdata_bytes ( ) const
inlinenoexcept

A const pointer to the raw storage, reinterpreted as byte data.

Definition at line 612 of file PackedListI.H.

References Foam::noexcept.

Referenced by writeList().

Here is the caller graph for this function:

◆ data_bytes()

template<unsigned Width>
char * data_bytes ( )
inlinenoexcept

A pointer to the raw storage, reinterpreted as byte data.

Definition at line 619 of file PackedListI.H.

References blocks_, and Foam::noexcept.

Referenced by readList().

Here is the caller graph for this function:

◆ size_data()

template<unsigned Width>
std::streamsize size_data ( ) const
inlinenoexcept

The number of integer blocks addressed in the raw storage. Same as num_blocks().

Definition at line 626 of file PackedListI.H.

References Foam::noexcept, num_blocks(), and size().

Here is the call graph for this function:

◆ size_bytes()

template<unsigned Width>
std::streamsize size_bytes ( ) const
inlinenoexcept

The number of bytes addressed in the raw storage including any padding.

Definition at line 633 of file PackedListI.H.

References Foam::noexcept, num_blocks(), and size().

Referenced by byteSize(), PackedList< Width >::hasher::operator()(), readList(), and writeList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ byteSize()

template<unsigned Width>
std::streamsize byteSize ( ) const
inlinenoexcept

Same as size_bytes().

Definition at line 640 of file PackedListI.H.

References Foam::noexcept, and size_bytes().

Here is the call graph for this function:

◆ printBits()

template<unsigned Width>
Foam::Ostream & printBits ( Ostream & os,
bool debugOutput = false ) const

Print bit patterns, optionally with extra debug.

Definition at line 36 of file PackedListIO.C.

References token::BEGIN_LIST, blocks_, token::END_LIST, Foam::nl, num_blocks(), os(), Foam::BitOps::print(), and size().

Here is the call graph for this function:

◆ readList()

◆ writeList()

template<unsigned Width>
Foam::Ostream & writeList ( Ostream & os,
label shortLen = 0 ) const

Write List, with line-breaks in ASCII when length exceeds shortLen.

Using '0' suppresses line-breaks entirely.

Definition at line 171 of file PackedListIO.C.

References token::BEGIN_BLOCK, token::BEGIN_LIST, IOstreamOption::BINARY, cdata_bytes(), token::END_BLOCK, token::END_LIST, get(), Foam::nl, os(), PackedList(), size(), size_bytes(), token::SPACE, and uniform().

Referenced by Foam::operator<<(), and Foam::operator<<().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeEntry() [2/2]

template<unsigned Width>
void writeEntry ( const word & keyword,
Ostream & os ) const

Write as a dictionary entry with keyword.

Definition at line 262 of file PackedListIO.C.

References os().

Here is the call graph for this function:

◆ push_back()

template<unsigned Width>
void push_back ( const unsigned int val)
inline

Append a value at the end of the list.

Definition at line 740 of file PackedListI.H.

Referenced by append(), and readList().

Here is the caller graph for this function:

◆ pop_back()

template<unsigned Width>
void pop_back ( label n = 1)
inline

Reduce size by 1 or more elements. Can be called on an empty list.

Definition at line 751 of file PackedListI.H.

◆ remove()

template<unsigned Width>
unsigned int remove ( )
inline

Remove and return the last element.

Definition at line 765 of file PackedListI.H.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, PackedList< Width >::reference::get(), resize(), and size().

Here is the call graph for this function:

◆ operator[]() [1/2]

template<unsigned Width>
unsigned int operator[] ( const label i) const
inline

Identical to get() - get value at index.

Never auto-vivify entries.

Definition at line 811 of file PackedListI.H.

References get().

Here is the call graph for this function:

◆ operator[]() [2/2]

template<unsigned Width>
Foam::PackedList< Width >::reference operator[] ( const label i)
inline

Non-const access to value at index.

Fatal for out-of-range indices

Definition at line 819 of file PackedListI.H.

References checkIndex().

Here is the call graph for this function:

◆ operator=() [1/3]

template<unsigned Width>
void operator= ( const PackedList< Width > & list)
inline

Copy assignment.

Definition at line 829 of file PackedListI.H.

References copyAssign(), PackedList(), and Foam::rhs().

Referenced by bitSet::operator=(), and PackedList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [2/3]

template<unsigned Width>
void operator= ( PackedList< Width > && list)
inline

Move assignment.

Definition at line 836 of file PackedListI.H.

References PackedList(), Foam::rhs(), and transfer().

Here is the call graph for this function:

◆ operator=() [3/3]

template<unsigned Width>
void operator= ( const unsigned int val)
inline

Assign all entries to the given value. fill().

Definition at line 843 of file PackedListI.H.

References fill().

Here is the call graph for this function:

◆ info()

template<unsigned Width>
InfoProxy< PackedList< Width > > info ( ) const
inlinenoexcept

Return info proxy, used to print information to a stream.

Definition at line 761 of file PackedList.H.

References info(), Foam::noexcept, and PackedList().

Referenced by info(), and operator<<.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ assign() [1/2]

template<unsigned Width>
void assign ( const unsigned int val)
inline

Deprecated(2020-11) use fill().

Deprecated
(2020-11) use fill()

Definition at line 807 of file PackedList.H.

References fill().

Here is the call graph for this function:

◆ assign() [2/2]

template<unsigned Width>
void assign ( const PackedList< Width > & rhs)
inline

Deprecated(2020-11) use operator=.

Deprecated
(2020-11) use operator=

Definition at line 814 of file PackedList.H.

References PackedList(), and Foam::rhs().

Here is the call graph for this function:

◆ setSize()

template<unsigned Width>
void setSize ( const label n,
unsigned int val = 0u )
inline

Alias for resize().

Definition at line 819 of file PackedList.H.

References n, and resize().

Referenced by meshRefinement::markOutsideFaces().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ append()

template<unsigned Width>
PackedList< Width > & append ( const unsigned int val)
inline

Append a value at the end of the list.

FOAM_DEPRECATED_FOR(2022-10, "push_back()")

Definition at line 826 of file PackedList.H.

References PackedList(), and push_back().

Here is the call graph for this function:

◆ unpack() [4/6]

template<unsigned Width>
template<class IntType>
Foam::List< IntType > unpack ( ) const

Definition at line 179 of file PackedList.C.

◆ unpack() [5/6]

template<unsigned Width>
template<class IntType>
Foam::List< IntType > unpack ( const labelRange & range) const

Definition at line 235 of file PackedList.C.

◆ unpack() [6/6]

template<unsigned Width>
template<class IntType>
Foam::List< IntType > unpack ( const labelUList & locations) const

Definition at line 269 of file PackedList.C.

◆ repeated_value() [2/2]

unsigned int repeated_value ( unsigned val)
inlineprotected

Definition at line 216 of file PackedListI.H.

◆ readValue() [2/2]

unsigned int readValue ( Istream & is)
inlineprotected

Definition at line 221 of file PackedListI.H.

◆ setPair() [2/2]

void setPair ( Istream & is)
inlineprotected

Definition at line 226 of file PackedListI.H.

◆ operator<<

template<unsigned Width>
Ostream & operator<< ( Ostream & os,
const InfoProxy< PackedList< Width > > & info )
friend

References info(), os(), and PackedList().

◆ operator>>

template<unsigned Width>
Istream & operator>> ( Istream & is,
PackedList< Width > & list )
friend

References PackedList().

Member Data Documentation

◆ bits_per_block

template<unsigned Width>
unsigned bits_per_block = (std::numeric_limits<block_type>::digits)
staticconstexpr

The number of bits in a single block.

Note
Type name compatibility with boost::dynamic_bitset

Definition at line 163 of file PackedList.H.

Referenced by mask_lower().

◆ element_width

template<unsigned Width>
unsigned element_width = (Width)
staticconstexpr

The width of an individual element (in bits).

Definition at line 169 of file PackedList.H.

◆ elem_per_block

template<unsigned Width>
unsigned elem_per_block = (bits_per_block / Width)
staticconstexpr

The number of elements stored per data block.

Definition at line 174 of file PackedList.H.

Referenced by bitSet::assign(), capacity(), clear_trailing_bits(), first_not_block(), num_blocks(), trim(), and uniform().

◆ max_value

template<unsigned Width>
block_type max_value = ((1u << Width) - 1)
staticconstexpr

The max value for an element which is also the bit-mask of the individual element.

Eg, for Width=2: ((1 << 2) - 1) == 0b0011

Definition at line 182 of file PackedList.H.

Referenced by PackedList< Width >::reference::get(), readValue(), PackedList< Width >::reference::set(), setPair(), uniform(), and PackedList< 1 >::unpack().

◆ blocks_

◆ size_

template<unsigned Width>
label size_
protected

The documentation for this class was generated from the following files: