40 #ifndef Foam_FixedList_H 41 #define Foam_FixedList_H 56 #include <type_traits> 65 template<
class T,
unsigned N>
class FixedList;
66 template<
class T>
class UList;
68 template<
class T,
unsigned N>
69 Istream&
operator>>(Istream& is, FixedList<T, N>& list);
71 template<
class T,
unsigned N>
72 Ostream& operator<<(Ostream& os, const FixedList<T, N>& list);
79 template<
class T,
unsigned N>
85 "Size must be positive (non-zero) and fit as a signed int value" 168 inline FixedList(std::initializer_list<T> list);
174 template<
unsigned AnyNum>
227 template<
unsigned Index>
231 template<
unsigned Index>
248 inline label
fcIndex(const label i) const;
251 inline const
T&
fcValue(const label i) const;
258 inline label
rcIndex(const label i) const;
261 inline const
T&
rcValue(const label i) const;
270 inline
void checkStart(const label start) const;
288 label
find(const
T& val, label
pos = 0) const;
294 label
rfind(const
T& val, label
pos = -1) const;
300 inline
bool contains(const
T& val, label
pos = 0) const;
306 inline
void resize(const label
n);
315 inline void fill(
const T& val);
355 inline void operator=(std::initializer_list<T> list);
430 inline void swap(FixedList<T, N>& other);
438 bool operator==(
const FixedList<T, N>& list)
const;
441 bool operator!=(
const FixedList<T, N>& list)
const;
444 bool operator<(const FixedList<T, N>& list)
const;
447 bool operator>(
const FixedList<T, N>& list)
const;
450 bool operator<=(const FixedList<T, N>& list)
const;
453 bool operator>=(
const FixedList<T, N>& list)
const;
462 void writeEntry(
const word& keyword, Ostream&
os)
const;
466 Ostream&
writeList(Ostream&
os,
const label shortLen=0)
const;
472 friend Istream&
operator>> <
T,
N>
475 FixedList<T, N>& list
484 inline unsigned operator()
486 const FixedList<T, N>& obj,
490 if (is_contiguous<T>::value)
492 return Foam::Hasher(obj.cdata(), obj.size_bytes(), seed);
496 for (
const T& val : obj)
498 seed = op(val, seed);
506 template<
class Unused=
bool>
528 bool found(
const T& val, label
pos = 0)
const 538 template<
class T,
unsigned N>
539 struct is_contiguous<FixedList<
T,
N>> : is_contiguous<T> {};
542 template<
class T,
unsigned N>
543 struct is_contiguous_label<FixedList<
T,
N>> : is_contiguous_label<T> {};
546 template<
class T,
unsigned N>
547 struct is_contiguous_scalar<FixedList<
T,
N>> : is_contiguous_scalar<T> {};
550 template<
class T,
unsigned N>
551 struct Hash<FixedList<
T,
N>> : FixedList<T, N>::hasher {};
558 template<
class T,
unsigned N>
559 inline void Swap(FixedList<T, N>& a, FixedList<T, N>&
b)
568 template<
class T,
unsigned N>
569 Istream&
operator>>(Istream& is, FixedList<T, N>& list)
571 return list.readList(is);
577 template<
class T,
unsigned N>
578 Ostream& operator<<(Ostream& os, const FixedList<T, N>& list)
580 return list.writeList(
os, Detail::ListPolicy::short_length<T>::value);
void operator=(const T list[N])
Assignment to array operator. Takes linear time.
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.
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.
Template class for non-intrusive linked lists.
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.
static std::streamsize byteSize()
Number of contiguous bytes for the list data, runtime FatalError if type is not contiguous.
bool contains(const T &val, label pos=0) const
Is the value contained in 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.
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.
Forward declarations for SLList.
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 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...
label fcIndex(const label i) const
Return the forward circular index, i.e. next index which returns to the first at the end of the list...
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.
OBJstream os(runTime.globalPath()/outputName)
Database for solution data, solver performance and other reduced data.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
label rcIndex(const label i) const
Return the reverse circular index, i.e. previous index which returns to the last at the beginning of ...
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.
T value_type
The value type the FixedList contains.
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)
reverse_iterator rbegin()
Return reverse_iterator to begin reverse traversing the FixedList.
FOAM_DEPRECATED_FOR(2021-04, "hasher()") Hash()
Includes some standard C++ headers, defines global macros and templates used in multiple places by Op...
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.
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...
static const FixedList< T, N > & null()
Return a null FixedList.
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.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.