PackedList< nBits >::iteratorBase Class Reference

The iterator base for PackedList. More...

Inheritance diagram for PackedList< nBits >::iteratorBase:
Collaboration diagram for PackedList< nBits >::iteratorBase:

Public Member Functions

 iteratorBase (const iteratorBase &)=default
 Default copy constructor. More...
 
label key () const
 Return the element index corresponding to the iterator. More...
 
bool writeIfSet (Ostream &) const
 Write index/value for a non-zero entry. More...
 
bool operator== (const iteratorBase &) const
 Compare values (not positions) More...
 
bool operator!= (const iteratorBase &) const
 
void operator= (const iteratorBase &)
 Assign value, not position. More...
 
void operator= (const unsigned int val)
 Assign value. More...
 
 operator unsigned int () const
 Conversion operator. More...
 
OstreamprintInfo (Ostream &) const
 Print information and values. More...
 
bool writeIfSet (Ostream &os) const
 

Protected Member Functions

unsigned int get () const
 Get value as unsigned, no range-checking. More...
 
bool set (unsigned int)
 Set value, returning true if changed, no range-checking. More...
 
 iteratorBase ()
 Construct null. More...
 
 iteratorBase (const PackedList *, const label)
 Construct from base list and position index. More...
 

Protected Attributes

PackedListlist_
 Pointer to original list. More...
 
label index_
 Element index. More...
 

Friends

class PackedList
 

Detailed Description

template<unsigned nBits = 1>
class Foam::PackedList< nBits >::iteratorBase

The iterator base for PackedList.

Note: data and functions are protected, to allow reuse by iterator and prevent most external usage.

Definition at line 417 of file PackedList.H.

Constructor & Destructor Documentation

◆ iteratorBase() [1/3]

iteratorBase
inlineprotected

Construct null.

Definition at line 269 of file PackedListI.H.

◆ iteratorBase() [2/3]

iteratorBase ( const PackedList ,
const  label 
)
inlineprotected

Construct from base list and position index.

◆ iteratorBase() [3/3]

iteratorBase ( const iteratorBase )
default

Default copy constructor.

Member Function Documentation

◆ get()

unsigned int get
inlineprotected

Get value as unsigned, no range-checking.

Definition at line 290 of file PackedListI.H.

Referenced by PackedList< nBits >::get(), PackedList< nBits >::operator[](), PackedList< nBits >::iteratorBase::printInfo(), PackedList< nBits >::remove(), and PackedList< nBits >::iteratorBase::writeIfSet().

Here is the caller graph for this function:

◆ set()

bool set ( unsigned int  val)
inlineprotected

Set value, returning true if changed, no range-checking.

Definition at line 302 of file PackedListI.H.

Referenced by PackedList< nBits >::append(), PackedList< nBits >::set(), and PackedList< nBits >::unset().

Here is the caller graph for this function:

◆ key()

Foam::label key
inline

Return the element index corresponding to the iterator.

Definition at line 329 of file PackedListI.H.

◆ writeIfSet() [1/2]

bool writeIfSet ( Ostream os) const
inline

Write index/value for a non-zero entry.

The bool specialisation writes the index only

Definition at line 146 of file PackedListI.H.

References token::BEGIN_LIST, token::END_LIST, PackedList< nBits >::iteratorBase::get(), PackedList< nBits >::iteratorBase::index_, and token::SPACE.

Here is the call graph for this function:

◆ operator==()

bool operator== ( const iteratorBase iter) const
inline

Compare values (not positions)

Definition at line 336 of file PackedListI.H.

◆ operator!=()

bool operator!= ( const iteratorBase iter) const
inline

Definition at line 346 of file PackedListI.H.

◆ operator=() [1/2]

void operator= ( const iteratorBase iter)
inline

Assign value, not position.

This allows packed[0] = packed[3] for assigning values

Definition at line 356 of file PackedListI.H.

References PackedList< nBits >::get().

Here is the call graph for this function:

◆ operator=() [2/2]

void operator= ( const unsigned int  val)
inline

Assign value.

A non-existent entry will be auto-vivified.

Definition at line 367 of file PackedListI.H.

References PackedList< nBits >::resize().

Here is the call graph for this function:

◆ operator unsigned int()

operator unsigned int
inline

Conversion operator.

Never auto-vivify entries.

Definition at line 383 of file PackedListI.H.

◆ printInfo()

Foam::Ostream & printInfo ( Ostream os) const

Print information and values.

Definition at line 148 of file PackedList.C.

References PackedList< nBits >::iteratorBase::get(), PackedList< nBits >::iteratorBase::index_, Foam::nl, and PackedList< nBits >::packing().

Here is the call graph for this function:

◆ writeIfSet() [2/2]

bool writeIfSet ( Ostream os) const
inline

Definition at line 86 of file PackedListI.H.

Friends And Related Function Documentation

◆ PackedList

friend class PackedList
friend

Definition at line 419 of file PackedList.H.

Member Data Documentation

◆ list_

PackedList* list_
protected

Pointer to original list.

This also lets us use the default bitwise copy/assignment

Definition at line 427 of file PackedList.H.

Referenced by PackedList< nBits >::iterator::iterator(), PackedList< 1 >::iterator::operator*(), and PackedList< nBits >::iterator::operator=().

◆ index_


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