40 #ifndef Foam_FixedList_H 41 #define Foam_FixedList_H 62 template<
class T,
unsigned N>
class FixedList;
63 template<
class T>
class UList;
65 template<
class T,
unsigned N>
66 Istream&
operator>>(Istream& is, FixedList<T, N>& list);
68 template<
class T,
unsigned N>
69 Ostream& operator<<(Ostream& os, const FixedList<T, N>& list);
76 template<
class T,
unsigned N>
82 "Size must be positive (non-zero) and fit as a signed int value" 143 return NullObjectRef<FixedList<T, N>>();
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);
448 inline void swap(FixedList<T, N>& other);
456 bool operator==(
const FixedList<T, N>& list)
const;
459 bool operator!=(
const FixedList<T, N>& list)
const;
462 bool operator<(const FixedList<T, N>& list)
const;
465 bool operator>(
const FixedList<T, N>& list)
const;
468 bool operator<=(const FixedList<T, N>& list)
const;
471 bool operator>=(
const FixedList<T, N>& list)
const;
480 void writeEntry(
const word& keyword, Ostream&
os)
const;
484 Ostream&
writeList(Ostream&
os,
const label shortLen=0)
const;
490 friend Istream&
operator>> <
T,
N>
493 FixedList<T, N>& list
502 inline unsigned operator()
504 const FixedList<T, N>& obj,
508 if constexpr (is_contiguous_v<T>)
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>
548 bool found(
const T& val, label
pos = 0)
const 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_); }
566 template<
class T,
unsigned N>
567 struct is_contiguous<FixedList<
T,
N>> : is_contiguous<T> {};
570 template<
class T,
unsigned N>
571 struct is_contiguous_label<FixedList<
T,
N>> : is_contiguous_label<T> {};
574 template<
class T,
unsigned N>
575 struct is_contiguous_scalar<FixedList<
T,
N>> : is_contiguous_scalar<T> {};
578 template<
class T,
unsigned N>
579 struct Hash<FixedList<
T,
N>> : FixedList<T, N>::hasher {};
585 template<
class T,
unsigned N>
586 Istream&
operator>>(Istream& is, FixedList<T, N>& list)
588 return list.readList(is);
594 template<
class T,
unsigned N>
595 Ostream& operator<<(Ostream& os, const FixedList<T, N>& list)
612 template<
class T,
unsigned N>
613 inline void Swap(FixedList<T, N>& a, FixedList<T, N>&
b)
const char * cdata_bytes() const noexcept
Return pointer to the underlying array serving as data storage,.
void resize(const label n)
Dummy function, to make FixedList consistent with List Any resizing is ignored (Fatal with bad sizing...
bool found(const T &val, label pos=0) const
Same as contains()
bool operator!=(const FixedList< T, N > &list) const
The opposite of the equality operation. Takes linear time.
std::reverse_iterator< iterator > reverse_iterator
Reverse iterator (non-const access)
label difference_type
The difference between iterator objects.
T * pointer
The pointer type for non-const access to value_type items.
const T & const_reference
The type used for reading from constant value_type objects.
A 1D vector of objects of type <T> with a fixed length <N>.
iterator begin() noexcept
Return an iterator to begin traversing the FixedList.
static constexpr bool empty() noexcept
Always false since zero-sized FixedList is compile-time disabled.
void moveLast(const label i)
Move element to the last position.
bool operator==(const FixedList< T, N > &list) const
Equality operation on FixedLists of the same type.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
T & reference
The type used for storing into value_type objects.
void resize_fill(const label n, const T &val)
Set val for all elements. Any resizing is ignored (Fatal with bad sizing in full debug).
static std::streamsize byteSize()
Number of contiguous bytes for the list data, runtime FatalError if type is not contiguous.
label rcIndex(const label i) const noexcept
Return the reverse circular index, i.e. previous index which returns to the last at the beginning of ...
label fcIndex(const label i) const noexcept
Return the forward circular index, i.e. next index which returns to the first at the end of the list...
iterator end() noexcept
Return an iterator to end traversing the FixedList.
T & back() noexcept
Access last element of the list, position [N-1].
void checkIndex(const label i) const
Check index is within valid range [0,N)
autoPtr< FixedList< T, N > > clone() const
Clone.
bool contains(const T &val) const
True if the value is contained in the list.
void writeEntry(Ostream &os) const
Write the FixedList with its compound type.
void setSize(const label n)
Dummy function, to make FixedList consistent with List.
static constexpr unsigned max_size() noexcept
The dimensioned size (template parameter N) of the FixedList.
T & operator[](const label i)
Return element of FixedList.
label size_type
The type to represent the size of a FixedList.
std::reverse_iterator< const_iterator > const_reverse_iterator
Reverse iterator (const access)
static constexpr label size() noexcept
Return the number of elements in the FixedList.
dimensionedScalar pos(const dimensionedScalar &ds)
reverse_iterator rend()
Return reverse_iterator to end reverse traversing the FixedList.
const T * cdata() const noexcept
Return pointer to the underlying array serving as data storage.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
const T * const_iterator
Random access iterator for traversing FixedList.
bool operator>(const FixedList< T, N > &list) const
Compare two FixedLists lexicographically. Takes linear time.
static std::streamsize size_bytes() noexcept
Number of contiguous bytes for the list data,.
void checkStart(const label start) const
Check start is within valid range [0,size)
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
Istream & operator>>(Istream &, directionInfo &)
T & first() noexcept
Access first element of the list, position [0] - front()
void swapFirst(const label i)
Swap element with the first element.
void operator=(const UList< T > &list)
Assignment to UList operator. Takes linear time.
void fill(const T &val)
Assign all entries to the given value.
char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage,.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
T * iterator
Random access iterator for traversing FixedList.
T & get() noexcept
Element access using compile-time indexing.
void checkSize(const label size) const
Check size is identical to template parameter N.
static const FixedList< T, N > & null() noexcept
Return a null FixedList (reference to a nullObject). Read/write access is questionable.
OBJstream os(runTime.globalPath()/outputName)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const_iterator cbegin() const noexcept
Return const_iterator to begin traversing the constant FixedList.
const Vector< label > N(dict.get< Vector< label >>("N"))
const_reverse_iterator crend() const
Return const_reverse_iterator to end reverse traversing FixedList.
label rfind(const T &val, label pos=-1) const
Find index of the last occurrence of the value.
T & last() noexcept
Access last element of the list, position [N-1] - back()
unsigned Hasher(const void *data, size_t len, unsigned seed=0)
Bob Jenkins's 96-bit mixer hashing function (lookup3)
void resize_nocopy(const label n)
Dummy function, to make FixedList consistent with List Any resizing is ignored (Fatal with bad sizing...
T value_type
The value type the FixedList contains.
label find(const T &val) const
Find index of the first occurrence of the value.
T & front() noexcept
Access first element of the list, position [0].
const T & rcValue(const label i) const
Return reverse circular value (ie, previous value in the list)
Hash function class. The default definition is for primitives. Non-primitives used to hash entries on...
const T & fcValue(const label i) const
Return forward circular value (ie, next value in the list)
const T * const_pointer
The pointer type for const access to value_type items.
Istream & readList(Istream &is)
Read from Istream, discarding contents of existing List.
void Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
Exchange contents of lists - see DynamicList::swap().
reverse_iterator rbegin()
Return reverse_iterator to begin reverse traversing the FixedList.
FOAM_DEPRECATED_FOR(2021-04, "hasher()") Hash()
Includes some common C++ headers, defines global macros and templates used in multiple places by Open...
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
void moveFirst(const label i)
Move element to the first position.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
void swapLast(const label i)
Swap element with the last element.
const_iterator cend() const noexcept
Return const_iterator to end traversing the constant FixedList.
T * data() noexcept
Return pointer to the underlying array serving as data storage.
Number of items before requiring line-breaks in the list output.
const_reverse_iterator crbegin() const
Return const_reverse_iterator to begin reverse traversing FixedList.
void transfer(FixedList< T, N > &list)
Transfer by swapping using a move assignment for the content of the individual list elements...
bool operator>=(const FixedList< T, N > &list) const
Return true if !(a < b). Takes linear time.
FixedList()=default
Default construct.
void swap(FixedList< T, N > &other)
Swap lists by swapping the content of the individual list elements.