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...

Inheritance diagram for PackedList< Width >:
[legend]
Collaboration diagram for PackedList< Width >:
[legend]

Classes

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

Public Types

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

Public Member Functions

constexpr PackedList () noexcept
 Default construct, zero-sized and no allocation. More...
 
 PackedList (const label numElem)
 Construct for given number of elements, initializes values to 0. More...
 
 PackedList (const label numElem, const unsigned int val)
 
 PackedList (Istream &is)
 Construct from Istream. More...
 
 PackedList (const PackedList< Width > &list)
 Copy construct. More...
 
 PackedList (PackedList< Width > &&list)
 Move construct. More...
 
 PackedList (const PackedList< Width > &list, const labelUList &addr)
 Copy construct a subset. More...
 
template<class Addr >
 PackedList (const PackedList< Width > &list, const IndirectListBase< label, Addr > &addr)
 Copy construct a subset. More...
 
 PackedList (const PackedList< Width > &list, const labelRange &range)
 Copy construct a subset range. More...
 
 PackedList (const labelUList &values)
 Construct from a list of values. More...
 
template<class Addr >
 PackedList (const IndirectListBase< label, Addr > &values)
 Construct from a indirect list of values. More...
 
autoPtr< PackedList< Width > > clone () const
 Clone. More...
 
void checkIndex (const label i) const
 Check index is within valid range [0,size) More...
 
label size () const noexcept
 Number of entries. More...
 
bool empty () const noexcept
 True if the list is empty (ie, size() is zero). More...
 
label capacity () const noexcept
 The number of elements that can be stored with reallocating. More...
 
bool uniform () const
 True if all entries have identical values, and list is non-empty. More...
 
bool equal (const PackedList< Width > &other) const
 Test for equality of sizes and the bits set. More...
 
unsigned int get (const label i) const
 Get value at index i or 0 for out-of-range. More...
 
bool set (const label i, unsigned int val=~0u)
 Set value at index i, default value set is the max_value. More...
 
bool unset (const label i)
 Unset the entry at index i. More...
 
labelList values () const
 Return the values as a list of labels. More...
 
template<class IntType = unsigned int>
List< IntType > unpack () const
 Return the values as a list of integral type. More...
 
template<class IntType = unsigned int>
List< IntType > unpack (const labelRange &range) const
 Return the range of values as a list of integral type. More...
 
template<class IntType = unsigned int>
List< IntType > unpack (const labelUList &locations) const
 
void fill (const unsigned int val)
 Assign all entries to the given value. More...
 
bool trim (label minpos=-1)
 
void reset ()
 Clear all bits but do not adjust the addressable size. More...
 
void setCapacity (const label numElem)
 Alter the size of the underlying storage. More...
 
void resize (const label numElem, const unsigned int val=0u)
 Reset addressable list size, does not shrink the allocated size. More...
 
void resize_nocopy (const label numElem)
 Currently identical to resize. Subject to future change (Oct-2021) More...
 
void reserve (const label numElem)
 
void clear ()
 Clear the list, i.e. set addressable size to zero. More...
 
void clearStorage ()
 Clear the list and delete storage. More...
 
void shrink ()
 Shrink the allocated space to what is actually used. More...
 
void swap (PackedList< Width > &rhs)
 Swap contents with argument. More...
 
void transfer (PackedList< Width > &rhs)
 
label nBlocks () const
 The number of internal storage blocks. More...
 
const List< unsigned int > & storage () const
 Return the underlying storage blocks. More...
 
List< unsigned int > & storage ()
 Return the underlying storage blocks. More...
 
const unsigned int * cdata () const noexcept
 A const pointer to the raw storage. More...
 
unsigned int * data () noexcept
 A pointer to the raw storage. More...
 
const char * cdata_bytes () const noexcept
 A const pointer to the raw storage, reinterpreted as byte data. More...
 
char * data_bytes () noexcept
 A pointer to the raw storage, reinterpreted as byte data. More...
 
std::streamsize size_bytes () const noexcept
 
std::streamsize byteSize () const noexcept
 
OstreamprintBits (Ostream &os, bool debugOutput=false) const
 Print bit patterns, optionally with extra debug. More...
 
IstreamreadList (Istream &is)
 Clear list and read from stream. More...
 
OstreamwriteList (Ostream &os, const label shortLen=0) const
 Write List, with line-breaks in ASCII when length exceeds shortLen. More...
 
void writeEntry (const word &keyword, Ostream &os) const
 Write as a dictionary entry with keyword. More...
 
PackedList< Width > & append (const unsigned int val)
 Append a value at the end of the list. More...
 
unsigned int remove ()
 Remove and return the last element. More...
 
unsigned int operator[] (const label i) const
 Identical to get() - get value at index. More...
 
reference operator[] (const label i)
 Non-const access to value at index. More...
 
void operator= (const PackedList< Width > &lst)
 Copy assignment. More...
 
void operator= (PackedList< Width > &&lst)
 Move assignment. More...
 
void operator= (const unsigned int val)
 Assign all entries to the given value. fill() More...
 
InfoProxy< PackedList< Width > > info () const
 Return info proxy. More...
 
void assign (const unsigned int val)
 Deprecated(2020-11) use fill() More...
 
void assign (const PackedList< Width > &rhs)
 Deprecated(2020-11) use operator=. More...
 
void setSize (const label n, unsigned int val=0u)
 Alias for resize() More...
 
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. More...
 

Static Public Member Functions

static constexpr label num_blocks (label numElem) noexcept
 
static constexpr block_type mask_lower (unsigned elementOffset)
 Masking for all bits below the element offset. More...
 

Static Public Attributes

static constexpr unsigned bits_per_block = (std::numeric_limits<block_type>::digits)
 The number of bits in a single block. More...
 
static constexpr unsigned element_width = (Width)
 The width of an individual element (in bits). More...
 
static constexpr unsigned elem_per_block = (bits_per_block / Width)
 The number of elements stored per data block. More...
 
static constexpr block_type max_value = ((1u << Width) - 1)
 

Protected Types

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

Protected Member Functions

void setPair (Istream &is)
 Read an index/value pair and set accordingly. More...
 
void writeEntry (Ostream &os) const
 Write as a dictionary entry. More...
 
void clear_trailing_bits ()
 Clear any partial rubbish in the last addressable block. More...
 
void copyAssign (const PackedList< Width > &rhs)
 Copy assignment. More...
 
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)
 A fill value for complete blocks. More...
 
static unsigned int readValue (Istream &is)
 Read a list entry (allows for specialization) More...
 

Protected Attributes

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

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 126 of file PackedList.H.

Member Typedef Documentation

◆ block_type

typedef unsigned int block_type

The storage block type for bit elements.

Note
Type name compatibility with boost::dynamic_bitset

Definition at line 136 of file PackedList.H.

◆ block_container

typedef List<block_type> block_container
protected

The internal container for storing the blocks.

Definition at line 181 of file PackedList.H.

◆ const_reference

typedef unsigned int const_reference

Definition at line 229 of file PackedList.H.

Constructor & Destructor Documentation

◆ PackedList() [1/11]

constexpr PackedList
inlineconstexprnoexcept

Default construct, zero-sized and no allocation.

Definition at line 177 of file PackedListI.H.

◆ PackedList() [2/11]

PackedList ( const label  numElem)
inlineexplicit

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

Definition at line 185 of file PackedListI.H.

◆ PackedList() [3/11]

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 193 of file PackedListI.H.

◆ PackedList() [4/11]

PackedList ( Istream is)
inline

Construct from Istream.

Definition at line 210 of file PackedListI.H.

◆ PackedList() [5/11]

PackedList ( const PackedList< Width > &  list)
inline

Copy construct.

Definition at line 220 of file PackedListI.H.

◆ PackedList() [6/11]

PackedList ( PackedList< Width > &&  list)
inline

Move construct.

Definition at line 228 of file PackedListI.H.

◆ PackedList() [7/11]

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

Copy construct a subset.

Definition at line 34 of file PackedList.C.

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

Here is the call graph for this function:

◆ PackedList() [8/11]

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

Copy construct a subset.

Definition at line 53 of file PackedList.C.

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

Here is the call graph for this function:

◆ PackedList() [9/11]

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

Copy construct a subset range.

Definition at line 71 of file PackedList.C.

References PackedList< Width >::get(), Foam::pos(), range, and PackedList< Width >::set().

Here is the call graph for this function:

◆ PackedList() [10/11]

PackedList ( const labelUList values)
inlineexplicit

Construct from a list of values.

Definition at line 238 of file PackedListI.H.

◆ PackedList() [11/11]

PackedList ( const IndirectListBase< label, Addr > &  values)
inlineexplicit

Construct from a indirect list of values.

Definition at line 258 of file PackedListI.H.

References UList< T >::size(), and PackedList< Width >::values().

Here is the call graph for this function:

Member Function Documentation

◆ num_blocks()

static 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:147

But avoiding the modulus operation

Definition at line 163 of file PackedList.H.

Referenced by PackedList< 1 >::byteSize(), PackedList< Width >::fill(), PackedList< Width >::nBlocks(), PackedList< Width >::reserve(), PackedList< Width >::setCapacity(), PackedList< Width >::shrink(), and PackedList< Width >::size_bytes().

Here is the caller graph for this function:

◆ mask_lower()

static 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 170 of file PackedList.H.

Referenced by PackedList< 1 >::append().

Here is the caller graph for this function:

◆ repeated_value() [1/2]

unsigned int repeated_value ( unsigned  val)
inlinestaticprotected

A fill value for complete blocks.

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)

Definition at line 34 of file PackedListI.H.

Referenced by PackedList< 1 >::byteSize(), and PackedList< Width >::fill().

Here is the caller graph for this function:

◆ readValue() [1/2]

unsigned int readValue ( Istream is)
inlinestaticprotected

Read a list entry (allows for specialization)

Definition at line 41 of file PackedListI.H.

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

Referenced by PackedList< Width >::readList().

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

◆ setPair() [1/2]

void setPair ( Istream is)
inlineprotected

Read an index/value pair and set accordingly.

For bool specialization, read a single index value

Definition at line 58 of file PackedListI.H.

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

Referenced by PackedList< Width >::readList().

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

◆ writeEntry() [1/2]

void writeEntry ( Ostream os) const
protected

Write as a dictionary entry.

Definition at line 34 of file PackedListIO.C.

References os().

Here is the call graph for this function:

◆ clear_trailing_bits()

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 83 of file PackedListI.H.

Referenced by PackedList< Width >::fill(), and PackedList< Width >::setCapacity().

Here is the caller graph for this function:

◆ copyAssign()

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

Copy assignment.

Definition at line 142 of file PackedListI.H.

References PackedList< Width >::blocks_, and PackedList< Width >::size_.

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

Here is the caller graph for this function:

◆ clone()

Foam::autoPtr< Foam::PackedList< Width > > clone
inline

Clone.

Definition at line 281 of file PackedListI.H.

◆ checkIndex()

void checkIndex ( const label  i) const
inline

Check index is within valid range [0,size)

Definition at line 359 of file PackedListI.H.

References PackedList< Width >::size_.

Referenced by PackedList< Width >::operator[]().

Here is the caller graph for this function:

◆ size()

◆ empty()

bool empty
inlinenoexcept

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

Definition at line 384 of file PackedListI.H.

References PackedList< Width >::size_.

Referenced by dynamicRefineFvMesh::calculateProtectedCells(), ensightMesh::correct(), PatchTools::edgeNormals(), PackedList< Width >::fill(), and PatchTools::pointNormals().

Here is the caller graph for this function:

◆ capacity()

Foam::label capacity
inlinenoexcept

The number of elements that can be stored with reallocating.

Definition at line 391 of file PackedListI.H.

Referenced by Foam::operator<<().

Here is the caller graph for this function:

◆ uniform()

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

Definition at line 93 of file PackedList.C.

Referenced by PackedList< Width >::writeList().

Here is the caller graph for this function:

◆ equal()

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

Test for equality of sizes and the bits set.

Definition at line 152 of file PackedList.C.

References PackedList< Width >::blocks_, and PackedList< Width >::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()

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 630 of file PackedListI.H.

References Foam::endl(), PackedList< Width >::reference::get(), PackedList< Width >::size(), PackedList< Width >::size_, and WarningInFunction.

Referenced by bitSet::bitSet(), hexRef8::consistentUnrefinement(), PackedList< Width >::reference::operator unsigned int(), PackedList< Width >::operator[](), and PackedList< Width >::PackedList().

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

◆ set()

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 652 of file PackedListI.H.

References Foam::endl(), PackedList< Width >::resize(), PackedList< Width >::reference::set(), PackedList< Width >::size(), PackedList< Width >::size_, and WarningInFunction.

Referenced by PackedList< 1 >::fill(), PackedList< Width >::reference::operator=(), PackedList< 1 >::PackedList(), PackedList< Width >::PackedList(), PackedList< Width >::readList(), syncTools::syncFaceList(), and fileMonitor::updateStates().

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

◆ unset()

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 684 of file PackedListI.H.

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

Here is the call graph for this function:

◆ values()

Return the values as a list of labels.

Definition at line 175 of file PackedList.C.

Referenced by PackedList< 1 >::PackedList(), and PackedList< Width >::PackedList().

Here is the caller graph for this function:

◆ unpack() [1/6]

List< IntType > unpack ( ) const

Return the values as a list of integral type.

The default integral type is unsigned int.

◆ unpack() [2/6]

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.

◆ unpack() [3/6]

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.

◆ fill()

void fill ( const unsigned int  val)
inline

Assign all entries to the given value.

Definition at line 728 of file PackedListI.H.

References PackedList< Width >::blocks_, PackedList< Width >::clear_trailing_bits(), PackedList< Width >::empty(), PackedList< Width >::num_blocks(), PackedList< Width >::repeated_value(), and PackedList< Width >::size().

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

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

◆ trim()

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 97 of file PackedListI.H.

Referenced by Foam::reorder().

Here is the caller graph for this function:

◆ reset()

void reset
inline

Clear all bits but do not adjust the addressable size.

Note
Method name compatibility with boost::dynamic_bitset

Definition at line 505 of file PackedListI.H.

References PackedList< Width >::blocks_.

Referenced by Foam::calcElementMasks(), parcelSelection::calculateFilter(), dynamicRefineFvMesh::calculateProtectedCells(), PackedList< Width >::clear(), distanceSurface::filterRegionProximity(), dynamicMultiMotionSolverFvMesh::init(), multiSolidBodyMotionSolver::multiSolidBodyMotionSolver(), and topoBitSet::reset().

Here is the caller graph for this function:

◆ setCapacity()

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 471 of file PackedListI.H.

References PackedList< Width >::blocks_, PackedList< Width >::clear_trailing_bits(), PackedList< Width >::num_blocks(), List< T >::resize(), PackedList< Width >::size(), and PackedList< Width >::size_.

Here is the call graph for this function:

◆ resize()

void resize ( const label  numElem,
const unsigned int  val = 0u 
)
inline

◆ resize_nocopy()

void resize_nocopy ( const label  numElem)
inline

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

Definition at line 398 of file PackedListI.H.

◆ reserve()

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 486 of file PackedListI.H.

References PackedList< Width >::blocks_, PackedList< Width >::num_blocks(), List< T >::resize(), and UList< T >::size().

Referenced by PackedList< Width >::append(), Foam::reorder(), and PackedList< 1 >::size_bytes().

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

◆ clear()

void clear
inline

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

Does not adjust the underlying storage

Definition at line 512 of file PackedListI.H.

References PackedList< Width >::reset(), and PackedList< Width >::size_.

Referenced by parcelSelection::calculateFilter(), dynamicRefineFvMesh::calculateProtectedCells(), and PackedList< Width >::readList().

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

◆ clearStorage()

void clearStorage
inline

Clear the list and delete storage.

Definition at line 520 of file PackedListI.H.

References PackedList< Width >::blocks_, List< T >::clear(), and PackedList< Width >::size_.

Referenced by ensightMesh::correct(), distanceSurface::createGeometry(), distanceSurface::filterKeepLargestRegion(), distanceSurface::filterKeepNearestRegions(), distanceSurface::filterRegionProximity(), cellZoneSet::updateSet(), faceZoneSet::updateSet(), and pointZoneSet::updateSet().

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

◆ shrink()

void shrink
inline

Shrink the allocated space to what is actually used.

Definition at line 528 of file PackedListI.H.

References PackedList< Width >::blocks_, PackedList< Width >::num_blocks(), List< T >::resize(), PackedList< Width >::size(), and UList< T >::size().

Here is the call graph for this function:

◆ swap()

void swap ( PackedList< Width > &  rhs)
inline

Swap contents with argument.

Definition at line 603 of file PackedListI.H.

References PackedList< Width >::blocks_, PackedList< Width >::size_, and UList< T >::swap().

Referenced by bitSet::swap().

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

◆ transfer()

void transfer ( PackedList< Width > &  rhs)
inline

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

Definition at line 616 of file PackedListI.H.

References PackedList< Width >::blocks_, PackedList< Width >::size_, and List< T >::transfer().

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

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

◆ nBlocks()

Foam::label nBlocks
inline

The number of internal storage blocks.

Definition at line 554 of file PackedListI.H.

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

Here is the call graph for this function:

◆ storage() [1/2]

const Foam::List< unsigned int > & storage
inline

Return the underlying storage blocks.

Definition at line 547 of file PackedListI.H.

References PackedList< Width >::blocks_.

Referenced by fileMonitor::updateStates().

Here is the caller graph for this function:

◆ storage() [2/2]

Foam::List< unsigned int > & storage
inline

Return the underlying storage blocks.

Manipulate with utmost caution

Definition at line 540 of file PackedListI.H.

References PackedList< Width >::blocks_.

◆ cdata()

const unsigned int * cdata
inlinenoexcept

A const pointer to the raw storage.

Definition at line 561 of file PackedListI.H.

References PackedList< Width >::blocks_, and UList< T >::cdata().

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

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

◆ data()

unsigned int * data
inlinenoexcept

A pointer to the raw storage.

Definition at line 568 of file PackedListI.H.

References PackedList< Width >::blocks_, and UList< T >::data().

Here is the call graph for this function:

◆ cdata_bytes()

const char * cdata_bytes
inlinenoexcept

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

Definition at line 575 of file PackedListI.H.

References PackedList< Width >::blocks_, and UList< T >::cdata_bytes().

Referenced by syncTools::syncFaceList(), and PackedList< Width >::writeList().

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

◆ data_bytes()

char * data_bytes
inlinenoexcept

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

Definition at line 582 of file PackedListI.H.

References PackedList< Width >::blocks_, and UList< T >::data_bytes().

Referenced by PackedList< Width >::readList(), and syncTools::syncFaceList().

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

◆ size_bytes()

std::streamsize size_bytes
inlinenoexcept

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

Definition at line 589 of file PackedListI.H.

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

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

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

◆ byteSize()

std::streamsize byteSize
inlinenoexcept

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

Definition at line 596 of file PackedListI.H.

References PackedList< Width >::size_bytes().

Here is the call graph for this function:

◆ printBits()

Foam::Ostream & printBits ( Ostream os,
bool  debugOutput = false 
) const

Print bit patterns, optionally with extra debug.

Definition at line 43 of file PackedListIO.C.

References Foam::nl, and os().

Here is the call graph for this function:

◆ readList()

◆ writeList()

Foam::Ostream & writeList ( Ostream os,
const label  shortLen = 0 
) const

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

Using '0' suppresses line-breaks entirely.

Definition at line 178 of file PackedListIO.C.

References PackedList< Width >::cdata_bytes(), Foam::nl, os(), PackedList< Width >::size(), PackedList< Width >::size_bytes(), and PackedList< Width >::uniform().

Referenced by Foam::operator<<().

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

◆ writeEntry() [2/2]

void writeEntry ( const word keyword,
Ostream os 
) const

Write as a dictionary entry with keyword.

Definition at line 243 of file PackedListIO.C.

References Foam::endl(), and os().

Here is the call graph for this function:

◆ append()

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

Append a value at the end of the list.

Definition at line 697 of file PackedListI.H.

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

Referenced by PackedList< Width >::readList().

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

◆ remove()

unsigned int remove
inline

Remove and return the last element.

Definition at line 709 of file PackedListI.H.

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

Referenced by LList< LListBase, T >::remove(), UILList< LListBase, T >::remove(), and LList< LListBase, T >::removeHead().

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

◆ operator[]() [1/2]

unsigned int operator[] ( const label  i) const
inline

Identical to get() - get value at index.

Never auto-vivify entries.

Definition at line 755 of file PackedListI.H.

References PackedList< Width >::get().

Here is the call graph for this function:

◆ operator[]() [2/2]

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 763 of file PackedListI.H.

References PackedList< Width >::checkIndex().

Here is the call graph for this function:

◆ operator=() [1/3]

void operator= ( const PackedList< Width > &  lst)
inline

Copy assignment.

Definition at line 773 of file PackedListI.H.

References PackedList< Width >::copyAssign().

Referenced by bitSet::operator=().

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

◆ operator=() [2/3]

void operator= ( PackedList< Width > &&  lst)
inline

Move assignment.

Definition at line 780 of file PackedListI.H.

References PackedList< Width >::transfer().

Here is the call graph for this function:

◆ operator=() [3/3]

void operator= ( const unsigned int  val)
inline

Assign all entries to the given value. fill()

Definition at line 787 of file PackedListI.H.

References PackedList< Width >::fill().

Here is the call graph for this function:

◆ info()

InfoProxy< PackedList< Width > > info ( ) const
inline

Return info proxy.

Definition at line 510 of file PackedList.H.

◆ assign() [1/2]

void assign ( const unsigned int  val)
inline

Deprecated(2020-11) use fill()

Deprecated:
(2020-11) use fill()

Definition at line 550 of file PackedList.H.

◆ assign() [2/2]

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

Deprecated(2020-11) use operator=.

Deprecated:
(2020-11) use operator=

Definition at line 554 of file PackedList.H.

◆ setSize()

void setSize ( const label  n,
unsigned int  val = 0u 
)
inline

Alias for resize()

Definition at line 557 of file PackedList.H.

References n, and PackedList< Width >::resize().

Referenced by distributedTriSurfaceMesh::getVolumeType(), GlobalIOField< Type >::GlobalIOField(), meshRefinement::markOutsideFaces(), and tetDecomposer::setRefinement().

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

◆ unpack() [4/6]

Foam::List< IntType > unpack ( ) const

Definition at line 184 of file PackedList.C.

References Foam::output().

Here is the call graph for this function:

◆ unpack() [5/6]

Foam::List< IntType > unpack ( const labelRange range) const

Definition at line 236 of file PackedList.C.

References Foam::pos(), and range.

Here is the call graph for this function:

◆ unpack() [6/6]

Foam::List< IntType > unpack ( const labelUList locations) const

Definition at line 270 of file PackedList.C.

References Foam::output(), Foam::pos(), and UList< T >::size().

Here is the call graph for this function:

◆ repeated_value() [2/2]

unsigned int repeated_value ( unsigned  val)
inlineprotected

Definition at line 156 of file PackedListI.H.

◆ readValue() [2/2]

unsigned int readValue ( Istream is)
inlineprotected

Definition at line 161 of file PackedListI.H.

References Foam::readBool().

Here is the call graph for this function:

◆ setPair() [2/2]

void setPair ( Istream is)
inlineprotected

Definition at line 166 of file PackedListI.H.

References Foam::readLabel().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator

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

◆ operator>>

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

Member Data Documentation

◆ bits_per_block

constexpr 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 140 of file PackedList.H.

◆ element_width

constexpr unsigned element_width = (Width)
staticconstexpr

The width of an individual element (in bits).

Definition at line 144 of file PackedList.H.

◆ elem_per_block

constexpr unsigned elem_per_block = (bits_per_block / Width)
staticconstexpr

The number of elements stored per data block.

Definition at line 147 of file PackedList.H.

Referenced by PackedList< 1 >::byteSize().

◆ max_value

constexpr 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 152 of file PackedList.H.

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

◆ blocks_

◆ size_


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