40#ifndef Foam_FixedList_H
41#define Foam_FixedList_H
62template<
class T,
unsigned N>
class FixedList;
63template<
class T>
class UList;
65template<
class T,
unsigned N>
68template<
class T,
unsigned N>
76template<
class T,
unsigned N>
81 N && N <= std::numeric_limits<int>::max(),
82 "Size must be positive (non-zero) and fit as a signed int value"
166 inline FixedList(std::initializer_list<T> list);
172 template<
unsigned AnyNum>
222 template<
unsigned Index>
226 template<
unsigned Index>
246 inline const
T&
fcValue(const label i) const;
256 inline const
T&
rcValue(const label i) const;
265 inline
void checkStart(const label start) const;
280 inline
bool contains(const
T& val) const;
287 inline
bool contains(const
T& val, label
pos, label len = -1) const;
292 label
find(const
T& val) const;
299 label
find(const
T& val, label
pos, label len = -1) const;
305 label
rfind(const
T& val, label
pos = -1) const;
312 inline
void resize(const label
n);
326 inline void fill(
const T& val);
360 inline void operator=(std::initializer_list<T> list);
502 inline unsigned operator()
510 return Foam::Hasher(obj.cdata(), obj.size_bytes(), seed);
515 for (
const T& val : obj)
517 seed = op(val, seed);
526 template<
class Unused=
bool>
555 explicit FixedList(
const T list[
N]) { std::copy_n(list,
N, v_); }
559 void operator=(
const T list[
N]) { std::copy_n(list,
N, v_); }
566template<
class T,
unsigned N>
570template<
class T,
unsigned N>
574template<
class T,
unsigned N>
578template<
class T,
unsigned N>
585template<
class T,
unsigned N>
594template<
class T,
unsigned N>
612template<
class T,
unsigned N>
A 1D vector of objects of type <T> with a fixed length <N>.
const_iterator cend() const noexcept
void moveLast(const label i)
Move element to the last position.
FixedList(const FixedList< T, AnyNum > &list, const FixedList< label, N > &indices)
Copy construct from a subset of the input. No size check.
FixedList(std::initializer_list< T > list)
Construct from an initializer list. Runtime size check.
label size_type
The type to represent the size of a FixedList.
const T & operator[](const label i) const
Return element of constant FixedList.
void swap(FixedList< T, N > &other)
Swap lists by swapping the content of the individual list elements.
void operator=(Foam::zero)
Assign all entries to zero. fill().
void swapLast(const label i)
Swap element with the last element.
FixedList(Foam::zero)
Construct and initialize all entries to zero.
FixedList(const UList< T > &list)
Construct from UList. Runtime size check.
label difference_type
The difference between iterator objects.
void operator=(const FixedList< T, N > &list)
Copy assignment.
void setSize(const label n)
void resize_nocopy(const label n)
bool operator>=(const FixedList< T, N > &list) const
Return true if !(a < b). Takes linear time.
const_reverse_iterator crbegin() const
bool found(const T &val, label pos=0) const
Same as contains().
void resize_fill(const label n, const scalar &val)
static std::streamsize size_bytes() noexcept
void operator=(const UList< T > &list)
Assignment to UList operator. Takes linear time.
char * data_bytes() noexcept
T value_type
The value type the FixedList contains.
static constexpr label size() noexcept
const T * const_iterator
Random access iterator for traversing FixedList.
const_iterator cbegin() const noexcept
const T & last() const noexcept
Access last element of the list, position [N-1] - back().
void checkIndex(const label i) const
void swapFirst(const label i)
Swap element with the first element.
void fill(const T &val)
Assign all entries to the given value.
T * iterator
Random access iterator for traversing FixedList.
T & first() noexcept
Access first element of the list, position [0] - front().
void operator=(const T &val)
Assign all entries to the given value. fill().
std::reverse_iterator< const_iterator > const_reverse_iterator
Reverse iterator (const access).
bool contains(const scalar &val) const
const scalar & rcValue(const label i) const
bool operator<(const FixedList< T, N > &list) const
Compare two FixedLists lexicographically. Takes linear time.
T & last() noexcept
Access last element of the list, position [N-1] - back().
const_reverse_iterator crend() const
void transfer(FixedList< T, N > &list)
Transfer by swapping using a move assignment for the content of the individual list elements.
const T * cdata() const noexcept
Return pointer to the underlying array serving as data storage.
const T * const_pointer
The pointer type for const access to value_type items.
static const FixedList< T, N > & null() noexcept
Return a null FixedList (reference to a nullObject). Read/write access is questionable.
void fill(Foam::zero)
Assign all entries to zero.
T * pointer
The pointer type for non-const access to value_type items.
label rfind(const scalar &val, label pos=-1) const
static std::streamsize byteSize()
void resize(const label n)
void writeEntry(const word &keyword, Ostream &os) const
Write the list as a dictionary entry with keyword.
const scalar & fcValue(const label i) const
void operator=(const T list[N])
Deprecated: assignment from C-array.
FixedList(const FixedList< T, N > &list)
Copy construct.
static constexpr unsigned max_size() noexcept
The dimensioned size (template parameter N) of the FixedList.
bool operator<=(const FixedList< T, N > &list) const
Return true if !(a > b). Takes linear time.
label rcIndex(const label i) const noexcept
std::reverse_iterator< iterator > reverse_iterator
Reverse iterator (non-const access).
bool operator!=(const FixedList< T, N > &list) const
The opposite of the equality operation. Takes linear time.
T & reference
The type used for storing into value_type objects.
void operator=(FixedList< T, N > &&list)
Move assignment.
FixedList(const T list[N])
Deprecated: copy construct from C-array.
void checkSize(const label size) const
const char * cdata_bytes() const noexcept
void writeEntry(Ostream &os) const
Write the FixedList with its compound type.
const T & first() const noexcept
Access first element of the list, position [0] - front().
void operator=(std::initializer_list< T > list)
Assignment to an initializer list. Takes linear time.
FixedList(FixedList< T, N > &&list)
Move construct by using move assignment for the individual list elements.
void moveFirst(const label i)
Move element to the first position.
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
scalar & front() noexcept
Istream & readList(Istream &is)
Read from Istream, discarding contents of existing List.
FixedList(Istream &is)
Construct from Istream.
bool operator==(const FixedList< T, N > &list) const
Equality operation on FixedLists of the same type.
reverse_iterator rbegin()
T & operator[](const label i)
Return element of FixedList.
FixedList()=default
Default construct.
bool operator>(const FixedList< T, N > &list) const
Compare two FixedLists lexicographically. Takes linear time.
label find(const scalar &val) const
static constexpr bool empty() noexcept
FixedList(const UList< T > &list, const FixedList< label, N > &indices)
Copy construct from a subset of the input. No size check.
iterator begin() noexcept
Return an iterator to begin traversing the FixedList.
FixedList(const T &val)
Construct and initialize all entries to given value.
const T & const_reference
The type used for reading from constant value_type objects.
label fcIndex(const label i) const noexcept
void checkStart(const label start) const
autoPtr< FixedList< T, N > > clone() const
Clone.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A class for handling words, derived from Foam::string.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
OBJstream os(runTime.globalPath()/outputName)
dimensionedScalar pos(const dimensionedScalar &ds)
const T & NullObjectRef() noexcept
Const reference (of type T) to the nullObject.
unsigned Hasher(const void *data, size_t len, unsigned seed=0)
Bob Jenkins's 96-bit mixer hashing function (lookup3).
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
void Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
Exchange contents of lists - see DynamicList::swap().
Istream & operator>>(Istream &, directionInfo &)
constexpr bool is_contiguous_v
The is_contiguous value of Type (after stripping of qualifiers).
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Includes some common C++ headers, defines global macros and templates used in multiple places by Open...
#define FOAM_DEPRECATED_FOR(since, replacement)
Deprecated(2021-04) hashing functor. Use hasher().
FOAM_DEPRECATED_FOR(2021-04, "hasher()") Hash()
Hashing functor for FixedList.
Hash function class. The default definition is for primitives. Non-primitives used to hash entries on...
Number of items before requiring line-breaks in the list output.
A template class to specify if a data type is composed solely of Foam::label elements.
A template class to specify if a data type is composed solely of Foam::scalar elements.
A template class to specify that a data type can be considered as being contiguous in memory.
const Vector< label > N(dict.get< Vector< label > >("N"))