FixedList.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2017-2026 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::FixedList
29 
30 Description
31  A 1D vector of objects of type <T> with a fixed length <N>.
32 
33 SourceFiles
34  FixedList.txx
35  FixedListI.H
36  FixedListIO.txx
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef Foam_FixedList_H
41 #define Foam_FixedList_H
42 
43 #include "bool.H"
44 #include "label.H"
45 #include "uLabel.H"
46 #include "zero.H"
47 #include "stdFoam.H"
48 #include "nullObject.H"
49 #include "Hash.H"
50 #include "ListPolicy.H" // Also includes "contiguous"
51 #include "autoPtr.H"
52 
53 #include <cstddef>
54 #include <limits>
55 #include <tuple>
56 #include <utility>
57 
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 
60 namespace Foam
61 {
62 
63 // Forward Declarations
64 
65 template<class T, unsigned N> class FixedList;
66 template<class T> class UList;
67 
68 template<class T, unsigned N>
69 Istream& operator>>(Istream& is, FixedList<T, N>& list);
70 
71 template<class T, unsigned N>
72 Ostream& operator<<(Ostream& os, const FixedList<T, N>& list);
73 
74 
75 /*---------------------------------------------------------------------------*\
76  Class FixedList Declaration
77 \*---------------------------------------------------------------------------*/
78 
79 template<class T, unsigned N>
80 class FixedList
81 {
82  static_assert
83  (
85  "Size must be positive (non-zero) and fit as a signed int value"
86  );
87 
88  // Private Data
89 
90  //- Vector of values of type T of length N.
91  T v_[N];
92 
93 
94 protected:
95 
96  // Protected Member Functions
97 
98  //- Write the FixedList with its compound type
99  void writeEntry(Ostream& os) const;
100 
101 
102 public:
103 
104  // STL Type Definitions
105 
106  //- The value type the FixedList contains
107  typedef T value_type;
109  //- The pointer type for non-const access to value_type items
110  typedef T* pointer;
111 
112  //- The pointer type for const access to value_type items
113  typedef const T* const_pointer;
114 
115  //- The type used for storing into value_type objects
116  typedef T& reference;
117 
118  //- The type used for reading from constant value_type objects.
119  typedef const T& const_reference;
120 
121  //- Random access iterator for traversing FixedList
122  typedef T* iterator;
124  //- Random access iterator for traversing FixedList
125  typedef const T* const_iterator;
126 
127  //- The type to represent the size of a FixedList
128  typedef label size_type;
129 
130  //- The difference between iterator objects
131  typedef label difference_type;
132 
133  //- Reverse iterator (non-const access)
134  typedef std::reverse_iterator<iterator> reverse_iterator;
135 
136  //- Reverse iterator (const access)
137  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
139 
140  // Static Functions
141 
142  //- Return a null FixedList (reference to a nullObject).
143  //- Read/write access is questionable
144  static const FixedList<T, N>& null() noexcept
145  {
146  return NullObjectRef<FixedList<T, N>>();
147  }
149 
150  // Generated Methods
151 
152  //- Default construct
153  FixedList() = default;
154 
155  //- Copy construct
156  FixedList(const FixedList&) = default;
157 
158  //- Move construct
159  FixedList(FixedList&&) = default;
160 
161 
162  // Constructors
163 
164  //- Construct and initialize all entries to given value
165  inline explicit FixedList(const T& val);
166 
167  //- Construct and initialize all entries to zero
168  inline explicit FixedList(Foam::zero);
169 
170  //- Construct from an initializer list. Runtime size check
171  inline FixedList(std::initializer_list<T> list);
172 
173  //- Construct from UList. Runtime size check
174  inline explicit FixedList(const UList<T>& list);
175 
176  //- Copy construct from a subset of the input. No size check
177  template<unsigned AnyNum>
178  inline FixedList
179  (
180  const FixedList<T, AnyNum>& list,
181  const FixedList<label, N>& indices
182  );
183 
184  //- Copy construct from a subset of the input. No size check
185  inline FixedList
186  (
187  const UList<T>& list,
188  const FixedList<label, N>& indices
189  );
190 
191  //- Construct from Istream
192  explicit FixedList(Istream& is);
193 
194  //- Clone
195  inline autoPtr<FixedList<T, N>> clone() const;
196 
197 
198  // Member Functions
199 
200  // Access
201 
202  //- Return pointer to the underlying array serving as data storage.
203  inline constexpr const T* cdata() const noexcept;
204 
205  //- Return pointer to the underlying array serving as data storage.
206  inline constexpr T* data() noexcept;
207 
208  //- Return pointer to the underlying array serving as data storage,
209  // reinterpreted as byte data
210  // \note Only meaningful for contiguous data
211  inline constexpr const char* cdata_bytes() const noexcept;
212 
213  //- Return pointer to the underlying array serving as data storage,
214  // reinterpreted as byte data
215  // \note Only meaningful for contiguous data
216  inline constexpr char* data_bytes() noexcept;
217 
218  //- Number of contiguous bytes for the list data,
219  // \note Only meaningful for contiguous data
220  inline static std::streamsize size_bytes() noexcept;
221 
222  //- Number of contiguous bytes for the list data,
223  //- runtime FatalError if type is not contiguous
224  static std::streamsize byteSize();
225 
226  //- Element access using compile-time indexing
227  template<unsigned I>
228  inline constexpr T& get() noexcept;
229 
230  //- Element access using compile-time indexing
231  template<unsigned I>
232  inline constexpr const T& get() const noexcept;
233 
234  //- Access first element of the list, position [0]
235  inline constexpr T& front() noexcept;
236 
237  //- Access first element of the list, position [0]
238  inline constexpr const T& front() const noexcept;
239 
240  //- Access last element of the list, position [N-1]
241  inline constexpr T& back() noexcept;
242 
243  //- Access last element of the list, position [N-1]
244  inline constexpr const T& back() const noexcept;
245 
246  //- Return the forward circular index, i.e. next index
247  //- which returns to the first at the end of the list
248  inline constexpr label fcIndex(label i) const noexcept;
249 
250  //- Return forward circular value (ie, next value in the list)
251  inline const T& fcValue(label i) const;
252 
253  //- Return forward circular value (ie, next value in the list)
254  inline T& fcValue(label i);
255 
256  //- Return the reverse circular index, i.e. previous index
257  //- which returns to the last at the beginning of the list
258  inline constexpr label rcIndex(label i) const noexcept;
259 
260  //- Return reverse circular value (ie, previous value in the list)
261  inline const T& rcValue(label i) const;
262 
263  //- Return reverse circular value (ie, previous value in the list)
264  inline T& rcValue(label i);
265 
266 
267  // Check
268 
269  //- Check start is within valid range [0,size)
270  inline void checkStart(const label start) const;
271 
272  //- Check size is identical to template parameter N
273  inline void checkSize(const label size) const;
274 
275  //- Check index is within valid range [0,N)
276  inline void checkIndex(const label i) const;
277 
278  //- True if all entries have identical values, and list is non-empty
279  inline bool uniform() const;
280 
281 
282  // Search
283 
284  //- True if the value is contained in the list.
285  inline bool contains(const T& val) const;
286 
287  //- Is the value contained in the list?
288  // \param val The value to search for
289  // \param pos The first position to examine (no-op if -ve)
290  // \param len The length of the search region (-ve until the end)
291  // \return true if found.
292  inline bool contains(const T& val, label pos, label len = -1) const;
293 
294  //- Find index of the first occurrence of the value.
295  // \param val The value to search for
296  // \return position in list or -1 if not found.
297  label find(const T& val) const;
298 
299  //- Find index of the first occurrence of the value.
300  // \param val The value to search for
301  // \param pos The first position to examine (no-op if -ve)
302  // \param len The length of the search region (-ve until the end)
303  // \return position in list or -1 if not found.
304  label find(const T& val, label pos, label len = -1) const;
305 
306  //- Find index of the last occurrence of the value.
307  // Any occurrences after the end pos are ignored.
308  // Linear search.
309  // \return position in list or -1 if not found.
310  label rfind(const T& val, label pos = -1) const;
311 
312 
313  // Edit
314 
315  //- Dummy function, to make FixedList consistent with List
316  //- Any resizing is ignored (Fatal with bad sizing in full debug).
317  inline void resize(const label n);
318 
319  //- Set val for \em all elements.
320  //- Any resizing is ignored (Fatal with bad sizing in full debug).
321  inline void resize_fill(const label n, const T& val);
322 
323  //- Dummy function, to make FixedList consistent with List
324  //- Any resizing is ignored (Fatal with bad sizing in full debug).
325  inline void resize_nocopy(const label n);
326 
327  //- Dummy function, to make FixedList consistent with List
328  void setSize(const label n) { this->resize(n); }
329 
330  //- Assign all entries to the given value
331  inline void fill(const T& val);
332 
333  //- Assign all entries to zero
334  inline void fill(Foam::zero);
335 
336  //- Move element to the first position.
337  void moveFirst(const label i);
338 
339  //- Move element to the last position.
340  void moveLast(const label i);
341 
342  //- Swap element with the first element.
343  void swapFirst(const label i);
344 
345  //- Swap element with the last element.
346  void swapLast(const label i);
347 
348  //- Transfer by swapping using a move assignment for the content
349  //- of the individual list elements
350  inline void transfer(FixedList<T, N>& list);
351 
352 
353  // Member Operators
354 
355  //- Return element of FixedList
356  inline T& operator[](const label i);
357 
358  //- Return element of constant FixedList
359  inline const T& operator[](const label i) const;
360 
361  //- Assignment to UList operator. Takes linear time
362  inline void operator=(const UList<T>& list);
363 
364  //- Assignment to an initializer list. Takes linear time
365  inline void operator=(std::initializer_list<T> list);
366 
367  //- Assign all entries to the given value. fill()
368  inline void operator=(const T& val);
369 
370  //- Assign all entries to zero. fill()
371  inline void operator=(Foam::zero);
372 
373  //- Copy assignment
374  inline void operator=(const FixedList& list);
375 
376  //- Move assignment
377  inline void operator=(FixedList&& list);
378 
379 
380  // Random access iterator (non-const)
381 
382  //- Return an iterator to begin traversing the FixedList
383  inline iterator begin() noexcept;
384 
385  //- Return an iterator to end traversing the FixedList
386  inline iterator end() noexcept;
387 
388  //- Return iterator at offset i from begin,
389  //- clamped to [0,N] range
390  inline iterator begin(const int i) noexcept;
391 
392 
393  // Random access iterator (const)
394 
395  //- Return const_iterator to begin traversing the constant FixedList
396  inline const_iterator cbegin() const noexcept;
397 
398  //- Return const_iterator to end traversing the constant FixedList
399  inline const_iterator cend() const noexcept;
400 
401  //- Return const_iterator to begin traversing the constant FixedList
402  inline const_iterator begin() const noexcept;
403 
404  //- Return const_iterator to end traversing the constant FixedList
405  inline const_iterator end() const noexcept;
406 
407  //- Return const_iterator at offset i from begin,
408  //- clamped to [0,N] range
409  inline const_iterator cbegin(const int i) const noexcept;
410 
411  //- Return const_iterator at offset i from begin,
412  //- clamped to [0,N] range
413  inline const_iterator begin(const int i) const noexcept;
414 
415 
416  // Reverse iterator (non-const)
417 
418  //- Return reverse_iterator to begin reverse traversing the FixedList
419  inline reverse_iterator rbegin();
420 
421  //- Return reverse_iterator to end reverse traversing the FixedList
422  inline reverse_iterator rend();
423 
424 
425  // Reverse iterator (const)
426 
427  //- Return const_reverse_iterator to begin reverse traversing FixedList
428  inline const_reverse_iterator crbegin() const;
429 
430  //- Return const_reverse_iterator to end reverse traversing FixedList
431  inline const_reverse_iterator crend() const;
432 
433  //- Return const_reverse_iterator to begin reverse traversing FixedList
434  inline const_reverse_iterator rbegin() const;
435 
436  //- Return const_reverse_iterator to end reverse traversing FixedList
437  inline const_reverse_iterator rend() const;
438 
439 
440  // STL Member Functions
441 
442  //- Always false since zero-sized FixedList is compile-time disabled.
443  static constexpr bool empty() noexcept { return !N; }
444 
445  //- Return the number of elements in the FixedList
446  static constexpr label size() noexcept { return N; }
447 
448  //- The dimensioned size (template parameter N) of the FixedList
449  static constexpr unsigned max_size() noexcept { return N; }
450 
451  //- Swap lists by swapping the content of the individual list elements
452  // Essentially std::swap_ranges
453  inline void swap(FixedList<T, N>& other);
454 
455 
456  // STL Member Operators
457 
458  //- Equality operation on FixedLists of the same type.
459  // Returns true when the FixedLists are element-wise equal
460  // (using FixedList::value_type::operator==). Takes linear time
461  bool operator==(const FixedList& other) const;
462 
463  //- Compare two FixedLists lexicographically. Takes linear time
464  bool operator<(const FixedList& other) const;
465 
466  //- The opposite of the equality operation. Takes linear time
467  bool operator!=(const FixedList& other) const
468  {
469  return !(*this == other);
470  }
471 
472  //- Return true if !(a > b). Takes linear time
473  bool operator<=(const FixedList& other) const
474  {
475  return !(other < *this);
476  }
477 
478  //- Compare two FixedLists lexicographically. Takes linear time
479  bool operator>(const FixedList& other) const
480  {
481  return (other < *this);
482  }
483 
484  //- Return true if !(a < b). Takes linear time
485  bool operator>=(const FixedList& other) const
486  {
487  return !(*this < other);
488  }
489 
490 
491  // Reading/writing
492 
493  //- Read from Istream, discarding contents of existing List
494  Istream& readList(Istream& is);
495 
496  //- Write the list as a dictionary entry with keyword
497  void writeEntry(const word& keyword, Ostream& os) const;
498 
499  //- Write List, with line-breaks in ASCII when length exceeds shortLen.
500  // Using '0' suppresses line-breaks entirely.
501  Ostream& writeList(Ostream& os, const label shortLen=0) const;
502 
503 
504  // IOstream Operators
505 
506  //- Use the readList() method to read contents from Istream.
507  friend Istream& operator>> <T, N>
508  (
509  Istream& is,
510  FixedList<T, N>& list
511  );
512 
513 
514  // Hashing
515 
516  //- Hashing functor for FixedList.
517  struct hasher
518  {
519  inline unsigned operator()
520  (
521  const FixedList<T, N>& obj,
522  unsigned seed=0
523  ) const
524  {
525  if constexpr (is_contiguous_v<T>)
526  {
527  return Foam::Hasher(obj.cdata(), obj.size_bytes(), seed);
528  }
529  else
530  {
531  Foam::Hash<T> op;
532  for (const T& val : obj)
533  {
534  seed = op(val, seed);
535  }
536  return seed;
537  }
538  }
539  };
540 
541  //- Deprecated(2021-04) hashing functor. Use hasher()
542  // \deprecated(2021-04) - use hasher() functor
543  template<class Unused=bool>
544  struct Hash : FixedList<T, N>::hasher
545  {
546  FOAM_DEPRECATED_FOR(2021-04, "hasher()") Hash() {}
547  };
548 
549 
550  // Housekeeping
551 
552  //- Access first element of the list, position [0] - front()
553  T& first() noexcept { return front(); }
554 
555  //- Access first element of the list, position [0] - front()
556  const T& first() const noexcept { return front(); }
557 
558  //- Access last element of the list, position [N-1] - back()
559  T& last() noexcept { return back(); }
560 
561  //- Access last element of the list, position [N-1] - back()
562  const T& last() const noexcept { return back(); }
563 
564  //- Same as contains()
565  bool found(const T& val, label pos = 0) const
566  {
567  return this->contains(val, pos);
568  }
569 
570 
571  //- Deprecated: copy construct from C-array
572  explicit FixedList(const T list[N]) { std::copy_n(list, N, v_); }
573 
574  //- Deprecated: assignment from C-array
575  // \deprecated(2023-08) - use other assignment operators
576  void operator=(const T list[N]) { std::copy_n(list, N, v_); }
577 };
578 
579 
580 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
581 
582 //- FixedList is contiguous if the type is contiguous
583 template<class T, unsigned N>
584 struct is_contiguous<FixedList<T, N>> : is_contiguous<T> {};
585 
586 //- Check for FixedList of labels
587 template<class T, unsigned N>
588 struct is_contiguous_label<FixedList<T, N>> : is_contiguous_label<T> {};
589 
590 //- Check for FixedList of scalars
591 template<class T, unsigned N>
592 struct is_contiguous_scalar<FixedList<T, N>> : is_contiguous_scalar<T> {};
593 
594 //- Hashing for FixedList data
595 template<class T, unsigned N>
596 struct Hash<FixedList<T, N>> : FixedList<T, N>::hasher {};
597 
598 //- Test if FixedList is the base class
599 template<class T>
600 inline constexpr bool is_fixedlist_v
601  = stdFoam::is_template_nttp_base_of_v<Foam::FixedList, T>;
602 
603 
604 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
605 
606 //- Read List contents from Istream, list must have the proper size!
607 template<class T, unsigned N>
608 Istream& operator>>(Istream& is, FixedList<T, N>& list)
609 {
610  return list.readList(is);
611 }
612 
613 
614 //- Write List to Ostream, as per FixedList::writeList() with default length.
615 // The default short-length is given by Foam::ListPolicy::short_length
616 template<class T, unsigned N>
617 Ostream& operator<<(Ostream& os, const FixedList<T, N>& list)
618 {
619  return list.writeList(os, Foam::ListPolicy::short_length<T>::value);
620 }
621 
622 
623 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
625 } // End namespace Foam
626 
627 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
628 
629 namespace Foam
630 {
631 
632 //- Swap FixedList contents - see FixedList::swap().
633 // Essentially std::swap_ranges
634 template<class T, unsigned N>
635 inline void Swap(FixedList<T, N>& a, FixedList<T, N>& b)
636 {
637  a.swap(b);
638 }
639 
640 
641 // * * * * * * * * * * * * * * * ADL Lookups * * * * * * * * * * * * * * * * //
642 
643 template<std::size_t I, class T, unsigned N>
644 constexpr T& get(FixedList<T, N>& list) noexcept
645 {
646  static_assert(I < N, "FixedList index out-of-range");
647  return *(list.data() + I);
648 }
649 
650 template<std::size_t I, class T, unsigned N>
651 constexpr const T& get(const FixedList<T, N>& list) noexcept
652 {
653  static_assert(I < N, "FixedList index out-of-range");
654  return *(list.cdata() + I);
655 }
656 
657 template<std::size_t I, class T, unsigned N>
658 constexpr T&& get(FixedList<T, N>&& list) noexcept
659 {
660  static_assert(I < N, "FixedList index out-of-range");
661  return std::move(*(list.data() + I));
662 }
663 
664 template<std::size_t I, class T, unsigned N>
665 constexpr const T&& get(const FixedList<T, N>&& list) noexcept
666 {
667  static_assert(I < N, "FixedList index out-of-range");
668  return std::move(*(list.cdata() + I));
669 }
670 
671 } // End namespace Foam
672 
674 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
675 
676 // Specializations (structured binding)
677 namespace std
678 {
679 
680 //- The tuple_size of FixedList is (N)
681 template<class T, unsigned N>
682 struct tuple_size<Foam::FixedList<T, N>>
683 : std::integral_constant<std::size_t, N> {};
684 
685 //- Identical type for all elements of FixedList
686 template<std::size_t I, class T, unsigned N>
687 struct tuple_element<I, Foam::FixedList<T, N>> { using type = T; };
688 
689 } // End namespace std
690 
691 
692 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
693 
694 #include "FixedListI.H"
695 
696 // * * * * * * * * * * * * * * * Implementations * * * * * * * * * * * * * * //
697 
698 // FUTURE?
699 // template<class T, unsigned N>
700 // constexpr Foam::UList<T>::UList(const FixedList<T>& list) noexcept
701 // :
702 // UList<T>(const_cast<T*>(list.cdata()), list.size())
703 // {}
704 
705 
706 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
707 
708 #ifdef NoRepository
709  #include "FixedList.txx"
710  #include "FixedListIO.txx"
711 #endif
712 
713 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
714 
715 #endif
716 
717 // ************************************************************************* //
void resize(const label n)
Dummy function, to make FixedList consistent with List Any resizing is ignored (Fatal with bad sizing...
Definition: FixedListI.H:297
bool found(const T &val, label pos=0) const
Same as contains()
Definition: FixedList.H:785
constexpr T * data() noexcept
Return pointer to the underlying array serving as data storage.
Definition: FixedListI.H:105
std::reverse_iterator< iterator > reverse_iterator
Reverse iterator (non-const access)
Definition: FixedList.H:153
label difference_type
The difference between iterator objects.
Definition: FixedList.H:148
type
Types of root.
Definition: Roots.H:52
T * pointer
The pointer type for non-const access to value_type items.
Definition: FixedList.H:113
const T & const_reference
The type used for reading from constant value_type objects.
Definition: FixedList.H:128
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: HashTable.H:107
iterator begin() noexcept
Return an iterator to begin traversing the FixedList.
Definition: FixedListI.H:461
static constexpr bool empty() noexcept
Always false since zero-sized FixedList is compile-time disabled.
Definition: FixedList.H:619
void moveLast(const label i)
Move element to the last position.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
T & reference
The type used for storing into value_type objects.
Definition: FixedList.H:123
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).
Definition: FixedListI.H:306
bool operator<=(const FixedList &other) const
Return true if !(a > b). Takes linear time.
Definition: FixedList.H:665
const T & fcValue(label i) const
Return forward circular value (ie, next value in the list)
Definition: FixedListI.H:189
bool operator>=(const FixedList &other) const
Return true if !(a < b). Takes linear time.
Definition: FixedList.H:681
constexpr label rcIndex(label i) const noexcept
Return the reverse circular index, i.e. previous index which returns to the last at the beginning of ...
Definition: FixedListI.H:204
Definition: FixedList.H:920
iterator end() noexcept
Return an iterator to end traversing the FixedList.
Definition: FixedListI.H:509
void checkIndex(const label i) const
Check index is within valid range [0,N)
Definition: FixedListI.H:250
constexpr T & front() noexcept
Access first element of the list, position [0].
Definition: FixedListI.H:153
autoPtr< FixedList< T, N > > clone() const
Clone.
Definition: FixedListI.H:87
bool contains(const T &val) const
True if the value is contained in the list.
Definition: FixedListI.H:277
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.
Definition: FixedList.H:442
constexpr const char * cdata_bytes() const noexcept
Return pointer to the underlying array serving as data storage,.
Definition: FixedListI.H:113
static constexpr unsigned max_size() noexcept
The dimensioned size (template parameter N) of the FixedList.
Definition: FixedList.H:629
constexpr T & back() noexcept
Access last element of the list, position [N-1].
Definition: FixedListI.H:167
T & operator[](const label i)
Return element of FixedList.
Definition: FixedListI.H:382
label size_type
The type to represent the size of a FixedList.
Definition: FixedList.H:143
std::reverse_iterator< const_iterator > const_reverse_iterator
Reverse iterator (const access)
Definition: FixedList.H:158
static constexpr label size() noexcept
Return the number of elements in the FixedList.
Definition: FixedList.H:624
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
dimensionedScalar pos(const dimensionedScalar &ds)
constexpr label fcIndex(label i) const noexcept
Return the forward circular index, i.e. next index which returns to the first at the end of the list...
Definition: FixedListI.H:182
reverse_iterator rend()
Return reverse_iterator to end reverse traversing the FixedList.
Definition: FixedListI.H:557
static const Identity< scalar > I
Definition: Identity.H:100
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
static std::streamsize byteSize()
Number of contiguous bytes for the list data, runtime FatalError if type is not contiguous.
const T * const_iterator
Random access iterator for traversing FixedList.
Definition: FixedList.H:138
static std::streamsize size_bytes() noexcept
Number of contiguous bytes for the list data,.
Definition: FixedListI.H:128
void checkStart(const label start) const
Check start is within valid range [0,size)
Definition: FixedListI.H:225
Istream & operator>>(Istream &, directionInfo &)
T & first() noexcept
Access first element of the list, position [0] - front()
Definition: FixedList.H:765
void swapFirst(const label i)
Swap element with the first element.
void operator=(const UList< T > &list)
Assignment to UList operator. Takes linear time.
Definition: FixedListI.H:402
void fill(const T &val)
Assign all entries to the given value.
Definition: FixedListI.H:325
const T & rcValue(label i) const
Return reverse circular value (ie, previous value in the list)
Definition: FixedListI.H:211
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:105
constexpr char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage,.
Definition: FixedListI.H:121
T * iterator
Random access iterator for traversing FixedList.
Definition: FixedList.H:133
const direction noexcept
Definition: scalarImpl.H:265
void checkSize(const label size) const
Check size is identical to template parameter N.
Definition: FixedListI.H:238
static const FixedList< T, N > & null() noexcept
Return a null FixedList (reference to a nullObject). Read/write access is questionable.
Definition: FixedList.H:167
bool operator>(const FixedList &other) const
Compare two FixedLists lexicographically. Takes linear time.
Definition: FixedList.H:673
Istream & readList(Istream &is)
Read from Istream, discarding contents of existing List.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const volScalarField & T
const_iterator cbegin() const noexcept
Return const_iterator to begin traversing the constant FixedList.
Definition: FixedListI.H:477
label rfind(const T &val, label pos=-1) const
Find index of the last occurrence of the value.
const Vector< label > N(dict.get< Vector< label >>("N"))
constexpr bool is_fixedlist_v
Test if FixedList is the base class.
Definition: FixedList.H:836
const_reverse_iterator crend() const
Return const_reverse_iterator to end reverse traversing FixedList.
Definition: FixedListI.H:573
T & last() noexcept
Access last element of the list, position [N-1] - back()
Definition: FixedList.H:775
unsigned Hasher(const void *data, size_t len, unsigned seed=0)
Bob Jenkins&#39;s 96-bit mixer hashing function (lookup3)
Definition: Hasher.C:575
void resize_nocopy(const label n)
Dummy function, to make FixedList consistent with List Any resizing is ignored (Fatal with bad sizing...
Definition: FixedListI.H:316
label find(const T &val) const
Find index of the first occurrence of the value.
T value_type
The value type the FixedList contains.
Definition: FixedList.H:108
Hash function class. The default definition is for primitives. Non-primitives used to hash entries on...
Definition: Hash.H:47
constexpr T & get() noexcept
Element access using compile-time indexing.
Definition: FixedListI.H:136
const T * const_pointer
The pointer type for const access to value_type items.
Definition: FixedList.H:118
void Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
Exchange contents of lists - see DynamicList::swap().
Definition: DynamicList.H:694
constexpr const T * cdata() const noexcept
Return pointer to the underlying array serving as data storage.
Definition: FixedListI.H:97
reverse_iterator rbegin()
Return reverse_iterator to begin reverse traversing the FixedList.
Definition: FixedListI.H:533
FOAM_DEPRECATED_FOR(2021-04, "hasher()") Hash()
Definition: FixedList.H:756
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 ...
Definition: zero.H:57
bool operator==(const FixedList &other) const
Equality operation on FixedLists of the same type.
label n
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...
Definition: HashPtrTable.H:48
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.
Definition: FixedListI.H:525
Number of items before requiring line-breaks in the list output.
Definition: ListPolicy.H:56
const_reverse_iterator crbegin() const
Return const_reverse_iterator to begin reverse traversing FixedList.
Definition: FixedListI.H:549
void transfer(FixedList< T, N > &list)
Transfer by swapping using a move assignment for the content of the individual list elements...
Definition: FixedListI.H:367
bool operator<(const FixedList &other) const
Compare two FixedLists lexicographically. Takes linear time.
System bool.
Namespace for OpenFOAM.
FixedList()=default
Default construct.
void swap(FixedList< T, N > &other)
Swap lists by swapping the content of the individual list elements.
Definition: FixedListI.H:351
bool operator!=(const FixedList &other) const
The opposite of the equality operation. Takes linear time.
Definition: FixedList.H:657