FixedList< T, N > Class Template Reference

A 1D vector of objects of type <T> with a fixed length <N>. More...

Inheritance diagram for FixedList< T, N >:
[legend]
Collaboration diagram for FixedList< T, N >:
[legend]

Classes

struct  Hash
 Hashing function class for FixedList. More...
 

Public Types

typedef T value_type
 The value type the FixedList contains. More...
 
typedef Tpointer
 The pointer type for non-const access to value_type items. More...
 
typedef Treference
 The type used for storing into value_type objects. More...
 
typedef Titerator
 Random access iterator for traversing FixedList. More...
 
typedef label size_type
 The type to represent the size of a FixedList. More...
 
typedef label difference_type
 The difference between iterator objects. More...
 
typedef std::reverse_iterator< iteratorreverse_iterator
 Reverse iterator (non-const access) More...
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 Reverse iterator (const access) More...
 

Public Member Functions

 FixedList ()=default
 Null constructor. More...
 
 FixedList (const T &val)
 Construct and initialize all entries to given value. More...
 
 FixedList (const zero)
 Construct and initialize all entries to zero. More...
 
 FixedList (const T list[N])
 Copy construct from C-array. More...
 
 FixedList (const FixedList< T, N > &list)
 Copy constructor. More...
 
 FixedList (FixedList< T, N > &&list)
 
template<class InputIterator >
 FixedList (InputIterator begIter, InputIterator endIter)
 Construct given begin/end iterators. More...
 
 FixedList (std::initializer_list< T > list)
 Construct from an initializer list. More...
 
 FixedList (const UList< T > &list)
 Construct from UList. More...
 
 FixedList (const SLList< T > &list)
 Construct from SLList. More...
 
 FixedList (Istream &is)
 Construct from Istream. More...
 
autoPtr< FixedList< T, N > > clone () const
 Clone. More...
 
const Tcdata () const noexcept
 Return a const pointer to the first data element. More...
 
Tdata () noexcept
 Return a pointer to the first data element. More...
 
Tfirst () noexcept
 The first element of the list, position [0]. More...
 
const Tfirst () const noexcept
 The first element of the list, position [0]. More...
 
Tlast () noexcept
 The last element of the list, position [N-1]. More...
 
const Tlast () const noexcept
 The last element of the list, position [N-1]. More...
 
label fcIndex (const label i) const
 
const TfcValue (const label i) const
 Return forward circular value (ie, next value in the list) More...
 
TfcValue (const label i)
 Return forward circular value (ie, next value in the list) More...
 
label rcIndex (const label i) const
 
const TrcValue (const label i) const
 Return reverse circular value (ie, previous value in the list) More...
 
TrcValue (const label i)
 Return reverse circular value (ie, previous value in the list) More...
 
void checkStart (const label start) const
 Check start is within valid range [0,size) More...
 
void checkSize (const label size) const
 Check size is identical to template parameter N. More...
 
void checkIndex (const label i) const
 Check index is within valid range [0,N) More...
 
bool uniform () const
 True if all entries have identical values, and list is non-empty. More...
 
label find (const T &val, const label start=0) const
 Find index of the first occurence of the value. More...
 
bool found (const T &val, const label start=0) const
 True if the value if found in the list. Linear search. More...
 
void resize (const label n)
 Dummy resize function, to make FixedList consistent with List. More...
 
void setSize (const label n)
 Dummy setSize function, to make FixedList consistent with List. More...
 
void moveFirst (const label i)
 Move element to the first position. More...
 
void moveLast (const label i)
 Move element to the last position. More...
 
void swapFirst (const label i)
 Swap element with the first element. More...
 
void swapLast (const label i)
 Swap element with the last element. More...
 
void transfer (FixedList< T, N > &list)
 
Toperator[] (const label i)
 Return element of FixedList. More...
 
const Toperator[] (const label i) const
 Return element of constant FixedList. More...
 
void operator= (const T list[N])
 Assignment to array operator. Takes linear time. More...
 
void operator= (const UList< T > &list)
 Assignment to UList operator. Takes linear time. More...
 
void operator= (const SLList< T > &list)
 Assignment to SLList operator. Takes linear time. More...
 
void operator= (std::initializer_list< T > list)
 Assignment to an initializer list. Takes linear time. More...
 
void operator= (const T &val)
 Assignment of all entries to the given value. More...
 
void operator= (const FixedList< T, N > &list)
 Copy assignment. More...
 
void operator= (FixedList< T, N > &&list)
 Move assignment. More...
 
iterator begin ()
 Return an iterator to begin traversing the FixedList. More...
 
iterator end ()
 Return an iterator to end traversing the FixedList. More...
 
const_iterator cbegin () const
 Return const_iterator to begin traversing the constant FixedList. More...
 
const_iterator cend () const
 Return const_iterator to end traversing the constant FixedList. More...
 
const_iterator begin () const
 Return const_iterator to begin traversing the constant FixedList. More...
 
const_iterator end () const
 Return const_iterator to end traversing the constant FixedList. More...
 
reverse_iterator rbegin ()
 Return reverse_iterator to begin reverse traversing the FixedList. More...
 
reverse_iterator rend ()
 Return reverse_iterator to end reverse traversing the FixedList. More...
 
const_reverse_iterator crbegin () const
 Return const_reverse_iterator to begin reverse traversing FixedList. More...
 
const_reverse_iterator crend () const
 Return const_reverse_iterator to end reverse traversing FixedList. More...
 
const_reverse_iterator rbegin () const
 Return const_reverse_iterator to begin reverse traversing FixedList. More...
 
const_reverse_iterator rend () const
 Return const_reverse_iterator to end reverse traversing FixedList. More...
 
void swap (FixedList< T, N > &list)
 Swap lists by swapping the content of the individual list elements. More...
 
bool operator== (const FixedList< T, N > &list) const
 Equality operation on FixedLists of the same type. More...
 
bool operator!= (const FixedList< T, N > &list) const
 The opposite of the equality operation. Takes linear time. More...
 
bool operator< (const FixedList< T, N > &list) const
 Compare two FixedLists lexicographically. Takes linear time. More...
 
bool operator> (const FixedList< T, N > &list) const
 Compare two FixedLists lexicographically. Takes linear time. More...
 
bool operator<= (const FixedList< T, N > &list) const
 Return true if !(a > b). Takes linear time. More...
 
bool operator>= (const FixedList< T, N > &list) const
 Return true if !(a < b). Takes linear time. More...
 
void writeEntry (const word &keyword, Ostream &os) const
 Write the list as a dictionary entry with keyword. More...
 
OstreamwriteList (Ostream &os, const label shortLen=0) const
 Write List, with line-breaks in ASCII when length exceeds shortLen. More...
 

Static Public Member Functions

static const FixedList< T, N > & null ()
 Return a null FixedList. More...
 
static constexpr bool empty () noexcept
 Always false since zero-sized FixedList is compile-time disabled. More...
 
static constexpr label size () noexcept
 Return the number of elements in the FixedList. More...
 
static constexpr unsigned max_size () noexcept
 The dimensioned size (template parameter N) of the FixedList. More...
 

Public Attributes

const typedef Tconst_pointer
 The pointer type for const access to value_type items. More...
 
const typedef Tconst_reference
 The type used for reading from constant value_type objects. More...
 
const typedef Tconst_iterator
 Random access iterator for traversing FixedList. More...
 

Protected Member Functions

void writeEntry (Ostream &os) const
 Write the FixedList with its compound type. More...
 

Friends

Istreamoperator>> (Istream &is, FixedList< T, N > &list)
 Read from Istream, discarding contents of existing List. More...
 

Detailed Description

template<class T, unsigned N>
class Foam::FixedList< T, N >

A 1D vector of objects of type <T> with a fixed length <N>.

Source files

Definition at line 104 of file HashTable.H.

Member Typedef Documentation

◆ value_type

typedef T value_type

The value type the FixedList contains.

Definition at line 104 of file FixedList.H.

◆ pointer

typedef T* pointer

The pointer type for non-const access to value_type items.

Definition at line 107 of file FixedList.H.

◆ reference

typedef T& reference

The type used for storing into value_type objects.

Definition at line 113 of file FixedList.H.

◆ iterator

typedef T* iterator

Random access iterator for traversing FixedList.

Definition at line 119 of file FixedList.H.

◆ size_type

typedef label size_type

The type to represent the size of a FixedList.

Definition at line 125 of file FixedList.H.

◆ difference_type

The difference between iterator objects.

Definition at line 128 of file FixedList.H.

◆ reverse_iterator

typedef std::reverse_iterator<iterator> reverse_iterator

Reverse iterator (non-const access)

Definition at line 131 of file FixedList.H.

◆ const_reverse_iterator

typedef std::reverse_iterator<const_iterator> const_reverse_iterator

Reverse iterator (const access)

Definition at line 134 of file FixedList.H.

Constructor & Destructor Documentation

◆ FixedList() [1/11]

FixedList ( )
inlinedefault

Null constructor.

◆ FixedList() [2/11]

FixedList ( const T val)
inlineexplicit

Construct and initialize all entries to given value.

Definition at line 46 of file FixedListI.H.

◆ FixedList() [3/11]

FixedList ( const  zero)
inlineexplicit

Construct and initialize all entries to zero.

Definition at line 56 of file FixedListI.H.

◆ FixedList() [4/11]

FixedList ( const T  list[N])
inlineexplicit

Copy construct from C-array.

Definition at line 66 of file FixedListI.H.

◆ FixedList() [5/11]

FixedList ( const FixedList< T, N > &  list)
inline

Copy constructor.

Definition at line 76 of file FixedListI.H.

◆ FixedList() [6/11]

FixedList ( FixedList< T, N > &&  list)
inline

Move construct by using move assignment for the individual list elements

Definition at line 86 of file FixedListI.H.

◆ FixedList() [7/11]

FixedList ( InputIterator  begIter,
InputIterator  endIter 
)
inline

Construct given begin/end iterators.

Uses std::distance when verifying the size.

Definition at line 98 of file FixedListI.H.

◆ FixedList() [8/11]

FixedList ( std::initializer_list< T list)
inline

Construct from an initializer list.

Definition at line 114 of file FixedListI.H.

◆ FixedList() [9/11]

FixedList ( const UList< T > &  list)
inlineexplicit

Construct from UList.

Definition at line 128 of file FixedListI.H.

◆ FixedList() [10/11]

FixedList ( const SLList< T > &  list)
inlineexplicit

Construct from SLList.

Definition at line 140 of file FixedListI.H.

◆ FixedList() [11/11]

FixedList ( Istream is)
explicit

Construct from Istream.

Definition at line 141 of file FixedListIO.C.

Member Function Documentation

◆ writeEntry() [1/2]

void writeEntry ( Ostream os) const
protected

Write the FixedList with its compound type.

Definition at line 37 of file FixedListIO.C.

◆ null()

const Foam::FixedList< T, N > & null ( )
inlinestatic

Return a null FixedList.

Definition at line 37 of file FixedListI.H.

◆ clone()

Foam::autoPtr< Foam::FixedList< T, N > > clone ( ) const
inline

Clone.

Definition at line 155 of file FixedListI.H.

◆ cdata()

const T * cdata ( ) const
inlinenoexcept

Return a const pointer to the first data element.

Similar to the STL front() method and the string::data() method This can be used (with caution) when interfacing with C code

Definition at line 165 of file FixedListI.H.

Referenced by FixedList< Type, 3 >::writeList().

Here is the caller graph for this function:

◆ data()

T * data ( )
inlinenoexcept

Return a pointer to the first data element.

Similar to the STL front() method and the string::data() method This can be used (with caution) when interfacing with C code

Definition at line 173 of file FixedListI.H.

◆ first() [1/2]

T & first ( )
inlinenoexcept

The first element of the list, position [0].

Definition at line 180 of file FixedListI.H.

Referenced by parProfiling::report(), and LangmuirHinshelwoodReactionRate::write().

Here is the caller graph for this function:

◆ first() [2/2]

const T & first ( ) const
inlinenoexcept

The first element of the list, position [0].

Definition at line 187 of file FixedListI.H.

◆ last() [1/2]

T & last ( )
inlinenoexcept

The last element of the list, position [N-1].

Definition at line 194 of file FixedListI.H.

◆ last() [2/2]

const T & last ( ) const
inlinenoexcept

The last element of the list, position [N-1].

Definition at line 201 of file FixedListI.H.

◆ fcIndex()

Foam::label fcIndex ( const label  i) const
inline

Return the forward circular index, i.e. next index which returns to the first at the end of the list

Definition at line 208 of file FixedListI.H.

Referenced by wallBoundedParticle::isTriAlongTrack(), and wallBoundedParticle::trackFaceTri().

Here is the caller graph for this function:

◆ fcValue() [1/2]

const T & fcValue ( const label  i) const
inline

Return forward circular value (ie, next value in the list)

Definition at line 215 of file FixedListI.H.

◆ fcValue() [2/2]

T & fcValue ( const label  i)
inline

Return forward circular value (ie, next value in the list)

Definition at line 222 of file FixedListI.H.

◆ rcIndex()

Foam::label rcIndex ( const label  i) const
inline

Return the reverse circular index, i.e. previous index which returns to the last at the beginning of the list

Definition at line 229 of file FixedListI.H.

◆ rcValue() [1/2]

const T & rcValue ( const label  i) const
inline

Return reverse circular value (ie, previous value in the list)

Definition at line 236 of file FixedListI.H.

◆ rcValue() [2/2]

T & rcValue ( const label  i)
inline

Return reverse circular value (ie, previous value in the list)

Definition at line 243 of file FixedListI.H.

◆ checkStart()

void checkStart ( const label  start) const
inline

Check start is within valid range [0,size)

Definition at line 250 of file FixedListI.H.

◆ checkSize()

void checkSize ( const label  size) const
inline

Check size is identical to template parameter N.

Definition at line 263 of file FixedListI.H.

◆ checkIndex()

void checkIndex ( const label  i) const
inline

Check index is within valid range [0,N)

Definition at line 275 of file FixedListI.H.

◆ uniform()

bool uniform ( ) const
inline

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

Definition at line 287 of file FixedListI.H.

◆ find()

Foam::label find ( const T val,
const label  start = 0 
) const

Find index of the first occurence of the value.

Linear search.

Returns
-1 if not found.

Definition at line 36 of file FixedList.C.

Referenced by triFace::which().

Here is the caller graph for this function:

◆ found()

bool found ( const T val,
const label  start = 0 
) const
inline

True if the value if found in the list. Linear search.

Definition at line 305 of file FixedListI.H.

Referenced by triFace::found().

Here is the caller graph for this function:

◆ resize()

void resize ( const label  n)
inline

Dummy resize function, to make FixedList consistent with List.

Definition at line 315 of file FixedListI.H.

◆ setSize()

void setSize ( const label  n)
inline

Dummy setSize function, to make FixedList consistent with List.

Definition at line 323 of file FixedListI.H.

Referenced by triSurfaceTools::collapseEdges(), blockDescriptor::facePoints(), shellSurfaces::findHigherGapLevel(), triSurfaceTools::mergePoints(), refinementHistory::refinementHistory(), refinementSurfaces::refinementSurfaces(), and shellSurfaces::shellSurfaces().

Here is the caller graph for this function:

◆ moveFirst()

void moveFirst ( const label  i)

Move element to the first position.

Definition at line 59 of file FixedList.C.

◆ moveLast()

void moveLast ( const label  i)

Move element to the last position.

Definition at line 71 of file FixedList.C.

◆ swapFirst()

void swapFirst ( const label  i)

Swap element with the first element.

Definition at line 83 of file FixedList.C.

◆ swapLast()

void swapLast ( const label  i)

Swap element with the last element.

Definition at line 95 of file FixedList.C.

◆ transfer()

void transfer ( FixedList< T, N > &  list)
inline

Transfer by swapping using a move assignment for the content of the individual list elements

Definition at line 347 of file FixedListI.H.

◆ operator[]() [1/2]

T & operator[] ( const label  i)
inline

Return element of FixedList.

Definition at line 364 of file FixedListI.H.

◆ operator[]() [2/2]

const T & operator[] ( const label  i) const
inline

Return element of constant FixedList.

Definition at line 374 of file FixedListI.H.

◆ operator=() [1/7]

void operator= ( const T  list[N])
inline

Assignment to array operator. Takes linear time.

Definition at line 384 of file FixedListI.H.

◆ operator=() [2/7]

void operator= ( const UList< T > &  list)
inline

Assignment to UList operator. Takes linear time.

Definition at line 393 of file FixedListI.H.

◆ operator=() [3/7]

void operator= ( const SLList< T > &  list)
inline

Assignment to SLList operator. Takes linear time.

Definition at line 404 of file FixedListI.H.

◆ operator=() [4/7]

void operator= ( std::initializer_list< T list)
inline

Assignment to an initializer list. Takes linear time.

Definition at line 417 of file FixedListI.H.

◆ operator=() [5/7]

void operator= ( const T val)
inline

Assignment of all entries to the given value.

Definition at line 430 of file FixedListI.H.

◆ operator=() [6/7]

void operator= ( const FixedList< T, N > &  list)
inline

Copy assignment.

Definition at line 439 of file FixedListI.H.

◆ operator=() [7/7]

void operator= ( FixedList< T, N > &&  list)
inline

Move assignment.

Definition at line 453 of file FixedListI.H.

◆ begin() [1/2]

Foam::FixedList< T, N >::iterator begin ( )
inline

Return an iterator to begin traversing the FixedList.

Definition at line 473 of file FixedListI.H.

Referenced by bitSet::bitSet(), edge::erase(), HashSet< Foam::string >::insert(), edge::insert(), Foam::operator*(), Foam::operator/(), HashSet< Foam::string >::operator=(), bitSet::set(), bitSet::unset(), and HashSet< Foam::string >::unset().

Here is the caller graph for this function:

◆ end() [1/2]

Foam::FixedList< T, N >::iterator end ( )
inline

Return an iterator to end traversing the FixedList.

Definition at line 497 of file FixedListI.H.

Referenced by bitSet::bitSet(), edge::erase(), HashSet< Foam::string >::insert(), edge::insert(), HashSet< Foam::string >::operator=(), bitSet::set(), bitSet::unset(), and HashSet< Foam::string >::unset().

Here is the caller graph for this function:

◆ cbegin()

Foam::FixedList< T, N >::const_iterator cbegin ( ) const
inline

Return const_iterator to begin traversing the constant FixedList.

Definition at line 489 of file FixedListI.H.

Referenced by HashTable< Foam::phase * >::erase().

Here is the caller graph for this function:

◆ cend()

Foam::FixedList< T, N >::const_iterator cend ( ) const
inline

Return const_iterator to end traversing the constant FixedList.

Definition at line 513 of file FixedListI.H.

Referenced by HashTable< Foam::phase * >::erase().

Here is the caller graph for this function:

◆ begin() [2/2]

Foam::FixedList< T, N >::const_iterator begin ( ) const
inline

Return const_iterator to begin traversing the constant FixedList.

Definition at line 481 of file FixedListI.H.

◆ end() [2/2]

Foam::FixedList< T, N >::const_iterator end ( ) const
inline

Return const_iterator to end traversing the constant FixedList.

Definition at line 505 of file FixedListI.H.

◆ rbegin() [1/2]

Foam::FixedList< T, N >::reverse_iterator rbegin ( )
inline

Return reverse_iterator to begin reverse traversing the FixedList.

Definition at line 521 of file FixedListI.H.

◆ rend() [1/2]

Foam::FixedList< T, N >::reverse_iterator rend ( )
inline

Return reverse_iterator to end reverse traversing the FixedList.

Definition at line 545 of file FixedListI.H.

◆ crbegin()

Foam::FixedList< T, N >::const_reverse_iterator crbegin ( ) const
inline

Return const_reverse_iterator to begin reverse traversing FixedList.

Definition at line 537 of file FixedListI.H.

◆ crend()

Foam::FixedList< T, N >::const_reverse_iterator crend ( ) const
inline

Return const_reverse_iterator to end reverse traversing FixedList.

Definition at line 561 of file FixedListI.H.

◆ rbegin() [2/2]

Foam::FixedList< T, N >::const_reverse_iterator rbegin ( ) const
inline

Return const_reverse_iterator to begin reverse traversing FixedList.

Definition at line 529 of file FixedListI.H.

◆ rend() [2/2]

Foam::FixedList< T, N >::const_reverse_iterator rend ( ) const
inline

Return const_reverse_iterator to end reverse traversing FixedList.

Definition at line 553 of file FixedListI.H.

◆ empty()

static constexpr bool empty ( )
inlinestaticconstexprnoexcept

Always false since zero-sized FixedList is compile-time disabled.

Definition at line 365 of file FixedList.H.

◆ size()

static constexpr label size ( )
inlinestaticconstexprnoexcept

Return the number of elements in the FixedList.

Definition at line 368 of file FixedList.H.

Referenced by DynamicList< Foam::FixedList< scalar, 3 > >::append(), isoSurface::generateFaceTriPoints(), indexedCell< Gt, Cb >::globallyOrderedCellVertices(), isoSurface::isoSurface(), isoSurfaceCell::isoSurfaceCell(), HashSet< Foam::string >::operator=(), pointConstraint::unconstrainedDirections(), and indexedCell< Gt, Cb >::vertexGlobalIndices().

Here is the caller graph for this function:

◆ max_size()

static constexpr unsigned max_size ( )
inlinestaticconstexprnoexcept

The dimensioned size (template parameter N) of the FixedList.

Definition at line 371 of file FixedList.H.

◆ swap()

void swap ( FixedList< T, N > &  list)
inline

Swap lists by swapping the content of the individual list elements.

Definition at line 332 of file FixedListI.H.

Referenced by Foam::Swap().

Here is the caller graph for this function:

◆ operator==()

bool operator== ( const FixedList< T, N > &  list) const

Equality operation on FixedLists of the same type.

Returns true when the FixedLists are element-wise equal (using FixedList::value_type::operator==). Takes linear time

Definition at line 111 of file FixedList.C.

◆ operator!=()

bool operator!= ( const FixedList< T, N > &  list) const

The opposite of the equality operation. Takes linear time.

Definition at line 155 of file FixedList.C.

◆ operator<()

bool operator< ( const FixedList< T, N > &  list) const

Compare two FixedLists lexicographically. Takes linear time.

Definition at line 131 of file FixedList.C.

◆ operator>()

bool operator> ( const FixedList< T, N > &  list) const

Compare two FixedLists lexicographically. Takes linear time.

Definition at line 162 of file FixedList.C.

◆ operator<=()

bool operator<= ( const FixedList< T, N > &  list) const

Return true if !(a > b). Takes linear time.

Definition at line 169 of file FixedList.C.

◆ operator>=()

bool operator>= ( const FixedList< T, N > &  list) const

Return true if !(a < b). Takes linear time.

Definition at line 176 of file FixedList.C.

◆ writeEntry() [2/2]

void writeEntry ( const word keyword,
Ostream os 
) const

Write the list as a dictionary entry with keyword.

Definition at line 52 of file FixedListIO.C.

◆ 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 68 of file FixedListIO.C.

Friends And Related Function Documentation

◆ operator>>

Istream& operator>> ( Istream is,
FixedList< T, N > &  list 
)
friend

Read from Istream, discarding contents of existing List.

Member Data Documentation

◆ const_pointer

const typedef T* const_pointer

The pointer type for const access to value_type items.

Definition at line 110 of file FixedList.H.

◆ const_reference

const typedef T& const_reference

The type used for reading from constant value_type objects.

Definition at line 116 of file FixedList.H.

◆ const_iterator

const typedef T* const_iterator

Random access iterator for traversing FixedList.

Definition at line 122 of file FixedList.H.


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