40 #ifndef Foam_FixedList_H 41 #define Foam_FixedList_H 57 #include <type_traits> 66 template<
class T,
unsigned N>
class FixedList;
67 template<
class T>
class UList;
69 template<
class T,
unsigned N>
70 Istream&
operator>>(Istream& is, FixedList<T, N>& list);
72 template<
class T,
unsigned N>
73 Ostream& operator<<(Ostream& os, const FixedList<T, N>& list);
80 template<
class T,
unsigned N>
86 "Size must be positive (non-zero) and fit as a signed int value" 147 return NullObjectRef<FixedList<T, N>>();
170 inline FixedList(std::initializer_list<T> list);
176 template<
unsigned AnyNum>
226 template<
unsigned Index>
230 template<
unsigned Index>
250 inline const
T&
fcValue(const label i) const;
260 inline const
T&
rcValue(const label i) const;
269 inline
void checkStart(const label start) const;
284 inline
bool contains(const
T& val) const;
291 inline
bool contains(const
T& val, label
pos, label len = -1) const;
296 label
find(const
T& val) const;
303 label
find(const
T& val, label
pos, label len = -1) const;
309 label
rfind(const
T& val, label
pos = -1) const;
316 inline
void resize(const label
n);
330 inline void fill(
const T& val);
364 inline void operator=(std::initializer_list<T> list);
440 inline void swap(FixedList<T, N>& other);
454 bool operator<(const FixedList<T, N>& list)
const;
460 bool operator<=(const FixedList<T, N>& list)
const;
494 inline unsigned operator()
502 return Foam::Hasher(obj.cdata(), obj.size_bytes(), seed);
506 for (
const T& val : obj)
508 seed = op(val, seed);
516 template<
class Unused=
bool>
538 bool found(
const T& val, label
pos = 0)
const 545 explicit FixedList(
const T list[
N]) { std::copy_n(list,
N, v_); }
549 void operator=(
const T list[
N]) { std::copy_n(list,
N, v_); }
556 template<
class T,
unsigned N>
557 struct is_contiguous<FixedList<
T,
N>> : is_contiguous<T> {};
560 template<
class T,
unsigned N>
561 struct is_contiguous_label<FixedList<
T,
N>> : is_contiguous_label<T> {};
564 template<
class T,
unsigned N>
565 struct is_contiguous_scalar<FixedList<
T,
N>> : is_contiguous_scalar<T> {};
568 template<
class T,
unsigned N>
569 struct Hash<FixedList<
T,
N>> : FixedList<T, N>::hasher {};
575 template<
class T,
unsigned N>
576 Istream&
operator>>(Istream& is, FixedList<T, N>& list)
578 return list.readList(is);
584 template<
class T,
unsigned N>
585 Ostream& operator<<(Ostream& os, const FixedList<T, N>& list)
587 return list.writeList(
os, Detail::ListPolicy::short_length<T>::value);
602 template<
class T,
unsigned N>
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.
A class for handling words, derived from Foam::string.
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.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
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...
A template class to specify that a data type can be considered as being contiguous in memory...
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 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.
T * data() noexcept
Return pointer to the underlying array serving as data storage.
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.