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-2025 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.C
35  FixedListI.H
36  FixedListIO.C
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 <limits>
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 // Forward Declarations
61 
62 template<class T, unsigned N> class FixedList;
63 template<class T> class UList;
64 
65 template<class T, unsigned N>
66 Istream& operator>>(Istream& is, FixedList<T, N>& list);
67 
68 template<class T, unsigned N>
69 Ostream& operator<<(Ostream& os, const FixedList<T, N>& list);
70 
71 
72 /*---------------------------------------------------------------------------*\
73  Class FixedList Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 template<class T, unsigned N>
77 class FixedList
78 {
79  static_assert
80  (
82  "Size must be positive (non-zero) and fit as a signed int value"
83  );
84 
85  // Private Data
86 
87  //- Vector of values of type T of length N.
88  T v_[N];
89 
90 
91 protected:
92 
93  // Protected Member Functions
94 
95  //- Write the FixedList with its compound type
96  void writeEntry(Ostream& os) const;
97 
98 
99 public:
100 
101  // STL Type Definitions
102 
103  //- The value type the FixedList contains
104  typedef T value_type;
106  //- The pointer type for non-const access to value_type items
107  typedef T* pointer;
108 
109  //- The pointer type for const access to value_type items
110  typedef const T* const_pointer;
111 
112  //- The type used for storing into value_type objects
113  typedef T& reference;
114 
115  //- The type used for reading from constant value_type objects.
116  typedef const T& const_reference;
117 
118  //- Random access iterator for traversing FixedList
119  typedef T* iterator;
121  //- Random access iterator for traversing FixedList
122  typedef const T* const_iterator;
123 
124  //- The type to represent the size of a FixedList
125  typedef label size_type;
126 
127  //- The difference between iterator objects
128  typedef label difference_type;
129 
130  //- Reverse iterator (non-const access)
131  typedef std::reverse_iterator<iterator> reverse_iterator;
132 
133  //- Reverse iterator (const access)
134  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
136 
137  // Static Functions
138 
139  //- Return a null FixedList (reference to a nullObject).
140  //- Read/write access is questionable
141  static const FixedList<T, N>& null() noexcept
142  {
143  return NullObjectRef<FixedList<T, N>>();
144  }
146 
147  // Constructors
148 
149  //- Default construct
150  FixedList() = default;
151 
152  //- Construct and initialize all entries to given value
153  inline explicit FixedList(const T& val);
154 
155  //- Construct and initialize all entries to zero
156  inline explicit FixedList(Foam::zero);
157 
158  //- Copy construct
159  inline FixedList(const FixedList<T, N>& list);
160 
161  //- Move construct by using move assignment for the individual
162  //- list elements
163  inline FixedList(FixedList<T, N>&& list);
165  //- Construct from an initializer list. Runtime size check
166  inline FixedList(std::initializer_list<T> list);
167 
168  //- Construct from UList. Runtime size check
169  inline explicit FixedList(const UList<T>& list);
170 
171  //- Copy construct from a subset of the input. No size check
172  template<unsigned AnyNum>
173  inline FixedList
174  (
175  const FixedList<T, AnyNum>& list,
176  const FixedList<label, N>& indices
177  );
178 
179  //- Copy construct from a subset of the input. No size check
180  inline FixedList
181  (
182  const UList<T>& list,
183  const FixedList<label, N>& indices
184  );
185 
186  //- Construct from Istream
187  explicit FixedList(Istream& is);
188 
189  //- Clone
190  inline autoPtr<FixedList<T, N>> clone() const;
191 
192 
193  // Member Functions
194 
195  // Access
196 
197  //- Return pointer to the underlying array serving as data storage.
198  inline const T* cdata() const noexcept;
199 
200  //- Return pointer to the underlying array serving as data storage.
201  inline T* data() noexcept;
202 
203  //- Return pointer to the underlying array serving as data storage,
204  // reinterpreted as byte data
205  // \note Only meaningful for contiguous data
206  inline const char* cdata_bytes() const 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 char* data_bytes() noexcept;
212 
213  //- Number of contiguous bytes for the list data,
214  // \note Only meaningful for contiguous data
215  inline static std::streamsize size_bytes() noexcept;
216 
217  //- Number of contiguous bytes for the list data,
218  //- runtime FatalError if type is not contiguous
219  static std::streamsize byteSize();
220 
221  //- Element access using compile-time indexing
222  template<unsigned Index>
223  inline T& get() noexcept;
224 
225  //- Element access using compile-time indexing
226  template<unsigned Index>
227  inline const T& get() const noexcept;
228 
229  //- Access first element of the list, position [0]
230  inline T& front() noexcept;
231 
232  //- Access first element of the list, position [0]
233  inline const T& front() const noexcept;
234 
235  //- Access last element of the list, position [N-1]
236  inline T& back() noexcept;
237 
238  //- Access last element of the list, position [N-1]
239  inline const T& back() const noexcept;
240 
241  //- Return the forward circular index, i.e. next index
242  //- which returns to the first at the end of the list
243  inline label fcIndex(const label i) const noexcept;
244 
245  //- Return forward circular value (ie, next value in the list)
246  inline const T& fcValue(const label i) const;
247 
248  //- Return forward circular value (ie, next value in the list)
249  inline T& fcValue(const label i);
250 
251  //- Return the reverse circular index, i.e. previous index
252  //- which returns to the last at the beginning of the list
253  inline label rcIndex(const label i) const noexcept;
254 
255  //- Return reverse circular value (ie, previous value in the list)
256  inline const T& rcValue(const label i) const;
257 
258  //- Return reverse circular value (ie, previous value in the list)
259  inline T& rcValue(const label i);
260 
261 
262  // Check
263 
264  //- Check start is within valid range [0,size)
265  inline void checkStart(const label start) const;
266 
267  //- Check size is identical to template parameter N
268  inline void checkSize(const label size) const;
269 
270  //- Check index is within valid range [0,N)
271  inline void checkIndex(const label i) const;
272 
273  //- True if all entries have identical values, and list is non-empty
274  inline bool uniform() const;
275 
276 
277  // Search
278 
279  //- True if the value is contained in the list.
280  inline bool contains(const T& val) const;
281 
282  //- Is the value contained in the list?
283  // \param val The value to search for
284  // \param pos The first position to examine (no-op if -ve)
285  // \param len The length of the search region (-ve until the end)
286  // \return true if found.
287  inline bool contains(const T& val, label pos, label len = -1) const;
288 
289  //- Find index of the first occurrence of the value.
290  // \param val The value to search for
291  // \return position in list or -1 if not found.
292  label find(const T& val) const;
293 
294  //- Find index of the first occurrence of the value.
295  // \param val The value to search for
296  // \param pos The first position to examine (no-op if -ve)
297  // \param len The length of the search region (-ve until the end)
298  // \return position in list or -1 if not found.
299  label find(const T& val, label pos, label len = -1) const;
300 
301  //- Find index of the last occurrence of the value.
302  // Any occurrences after the end pos are ignored.
303  // Linear search.
304  // \return position in list or -1 if not found.
305  label rfind(const T& val, label pos = -1) const;
306 
307 
308  // Edit
309 
310  //- Dummy function, to make FixedList consistent with List
311  //- Any resizing is ignored (Fatal with bad sizing in full debug).
312  inline void resize(const label n);
313 
314  //- Set val for \em all elements.
315  //- Any resizing is ignored (Fatal with bad sizing in full debug).
316  inline void resize_fill(const label n, const T& val);
317 
318  //- Dummy function, to make FixedList consistent with List
319  //- Any resizing is ignored (Fatal with bad sizing in full debug).
320  inline void resize_nocopy(const label n);
321 
322  //- Dummy function, to make FixedList consistent with List
323  void setSize(const label n) { this->resize(n); }
324 
325  //- Assign all entries to the given value
326  inline void fill(const T& val);
327 
328  //- Assign all entries to zero
329  inline void fill(Foam::zero);
330 
331  //- Move element to the first position.
332  void moveFirst(const label i);
333 
334  //- Move element to the last position.
335  void moveLast(const label i);
336 
337  //- Swap element with the first element.
338  void swapFirst(const label i);
339 
340  //- Swap element with the last element.
341  void swapLast(const label i);
342 
343  //- Transfer by swapping using a move assignment for the content
344  //- of the individual list elements
345  inline void transfer(FixedList<T, N>& list);
346 
347 
348  // Member Operators
349 
350  //- Return element of FixedList
351  inline T& operator[](const label i);
352 
353  //- Return element of constant FixedList
354  inline const T& operator[](const label i) const;
355 
356  //- Assignment to UList operator. Takes linear time
357  inline void operator=(const UList<T>& list);
358 
359  //- Assignment to an initializer list. Takes linear time
360  inline void operator=(std::initializer_list<T> list);
361 
362  //- Assign all entries to the given value. fill()
363  inline void operator=(const T& val);
364 
365  //- Assign all entries to zero. fill()
366  inline void operator=(Foam::zero);
367 
368  //- Copy assignment
369  inline void operator=(const FixedList<T, N>& list);
370 
371  //- Move assignment
372  inline void operator=(FixedList<T, N>&& list);
373 
374 
375  // Random access iterator (non-const)
376 
377  //- Return an iterator to begin traversing the FixedList
378  inline iterator begin() noexcept;
379 
380  //- Return an iterator to end traversing the FixedList
381  inline iterator end() noexcept;
382 
383  //- Return iterator at offset i from begin,
384  //- clamped to [0,N] range
385  inline iterator begin(const int i) noexcept;
386 
387 
388  // Random access iterator (const)
389 
390  //- Return const_iterator to begin traversing the constant FixedList
391  inline const_iterator cbegin() const noexcept;
392 
393  //- Return const_iterator to end traversing the constant FixedList
394  inline const_iterator cend() const noexcept;
395 
396  //- Return const_iterator to begin traversing the constant FixedList
397  inline const_iterator begin() const noexcept;
398 
399  //- Return const_iterator to end traversing the constant FixedList
400  inline const_iterator end() const noexcept;
401 
402  //- Return const_iterator at offset i from begin,
403  //- clamped to [0,N] range
404  inline const_iterator cbegin(const int i) const noexcept;
405 
406  //- Return const_iterator at offset i from begin,
407  //- clamped to [0,N] range
408  inline const_iterator begin(const int i) const noexcept;
409 
410 
411  // Reverse iterator (non-const)
412 
413  //- Return reverse_iterator to begin reverse traversing the FixedList
414  inline reverse_iterator rbegin();
415 
416  //- Return reverse_iterator to end reverse traversing the FixedList
417  inline reverse_iterator rend();
418 
419 
420  // Reverse iterator (const)
421 
422  //- Return const_reverse_iterator to begin reverse traversing FixedList
423  inline const_reverse_iterator crbegin() const;
424 
425  //- Return const_reverse_iterator to end reverse traversing FixedList
426  inline const_reverse_iterator crend() const;
427 
428  //- Return const_reverse_iterator to begin reverse traversing FixedList
429  inline const_reverse_iterator rbegin() const;
430 
431  //- Return const_reverse_iterator to end reverse traversing FixedList
432  inline const_reverse_iterator rend() const;
433 
434 
435  // STL Member Functions
436 
437  //- Always false since zero-sized FixedList is compile-time disabled.
438  static constexpr bool empty() noexcept { return !N; }
439 
440  //- Return the number of elements in the FixedList
441  static constexpr label size() noexcept { return N; }
442 
443  //- The dimensioned size (template parameter N) of the FixedList
444  static constexpr unsigned max_size() noexcept { return N; }
445 
446  //- Swap lists by swapping the content of the individual list elements
447  // Essentially std::swap_ranges
448  inline void swap(FixedList<T, N>& other);
449 
450 
451  // STL Member Operators
452 
453  //- Equality operation on FixedLists of the same type.
454  // Returns true when the FixedLists are element-wise equal
455  // (using FixedList::value_type::operator==). Takes linear time
456  bool operator==(const FixedList<T, N>& list) const;
457 
458  //- The opposite of the equality operation. Takes linear time
459  bool operator!=(const FixedList<T, N>& list) const;
460 
461  //- Compare two FixedLists lexicographically. Takes linear time
462  bool operator<(const FixedList<T, N>& list) const;
463 
464  //- Compare two FixedLists lexicographically. Takes linear time
465  bool operator>(const FixedList<T, N>& list) const;
466 
467  //- Return true if !(a > b). Takes linear time
468  bool operator<=(const FixedList<T, N>& list) const;
469 
470  //- Return true if !(a < b). Takes linear time
471  bool operator>=(const FixedList<T, N>& list) const;
472 
473 
474  // Reading/writing
475 
476  //- Read from Istream, discarding contents of existing List
477  Istream& readList(Istream& is);
478 
479  //- Write the list as a dictionary entry with keyword
480  void writeEntry(const word& keyword, Ostream& os) const;
481 
482  //- Write List, with line-breaks in ASCII when length exceeds shortLen.
483  // Using '0' suppresses line-breaks entirely.
484  Ostream& writeList(Ostream& os, const label shortLen=0) const;
485 
486 
487  // IOstream Operators
488 
489  //- Use the readList() method to read contents from Istream.
490  friend Istream& operator>> <T, N>
491  (
492  Istream& is,
493  FixedList<T, N>& list
494  );
495 
496 
497  // Hashing
498 
499  //- Hashing functor for FixedList.
500  struct hasher
501  {
502  inline unsigned operator()
503  (
504  const FixedList<T, N>& obj,
505  unsigned seed=0
506  ) const
507  {
508  if constexpr (is_contiguous_v<T>)
509  {
510  return Foam::Hasher(obj.cdata(), obj.size_bytes(), seed);
511  }
512  else
513  {
514  Foam::Hash<T> op;
515  for (const T& val : obj)
516  {
517  seed = op(val, seed);
518  }
519  return seed;
520  }
521  }
522  };
523 
524  //- Deprecated(2021-04) hashing functor. Use hasher()
525  // \deprecated(2021-04) - use hasher() functor
526  template<class Unused=bool>
527  struct Hash : FixedList<T, N>::hasher
528  {
529  FOAM_DEPRECATED_FOR(2021-04, "hasher()") Hash() {}
530  };
531 
532 
533  // Housekeeping
534 
535  //- Access first element of the list, position [0] - front()
536  T& first() noexcept { return front(); }
537 
538  //- Access first element of the list, position [0] - front()
539  const T& first() const noexcept { return front(); }
540 
541  //- Access last element of the list, position [N-1] - back()
542  T& last() noexcept { return back(); }
543 
544  //- Access last element of the list, position [N-1] - back()
545  const T& last() const noexcept { return back(); }
546 
547  //- Same as contains()
548  bool found(const T& val, label pos = 0) const
549  {
550  return this->contains(val, pos);
551  }
552 
553 
554  //- Deprecated: copy construct from C-array
555  explicit FixedList(const T list[N]) { std::copy_n(list, N, v_); }
556 
557  //- Deprecated: assignment from C-array
558  // \deprecated(2023-08) - use other assignment operators
559  void operator=(const T list[N]) { std::copy_n(list, N, v_); }
560 };
561 
562 
563 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
564 
565 //- FixedList is contiguous if the type is contiguous
566 template<class T, unsigned N>
567 struct is_contiguous<FixedList<T, N>> : is_contiguous<T> {};
568 
569 //- Check for FixedList of labels
570 template<class T, unsigned N>
571 struct is_contiguous_label<FixedList<T, N>> : is_contiguous_label<T> {};
572 
573 //- Check for FixedList of scalars
574 template<class T, unsigned N>
575 struct is_contiguous_scalar<FixedList<T, N>> : is_contiguous_scalar<T> {};
576 
577 //- Hashing for FixedList data
578 template<class T, unsigned N>
579 struct Hash<FixedList<T, N>> : FixedList<T, N>::hasher {};
580 
581 
582 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
583 
584 //- Read List contents from Istream, list must have the proper size!
585 template<class T, unsigned N>
586 Istream& operator>>(Istream& is, FixedList<T, N>& list)
587 {
588  return list.readList(is);
589 }
590 
591 
592 //- Write List to Ostream, as per FixedList::writeList() with default length.
593 // The default short-length is given by Foam::ListPolicy::short_length
594 template<class T, unsigned N>
595 Ostream& operator<<(Ostream& os, const FixedList<T, N>& list)
596 {
597  return list.writeList(os, Foam::ListPolicy::short_length<T>::value);
598 }
599 
600 
601 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
602 
603 } // End namespace Foam
604 
605 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
606 
607 namespace Foam
608 {
609 
610 //- Swap FixedList contents - see FixedList::swap().
611 // Essentially std::swap_ranges
612 template<class T, unsigned N>
613 inline void Swap(FixedList<T, N>& a, FixedList<T, N>& b)
614 {
615  a.swap(b);
616 }
617 
618 } // End namespace Foam
620 
621 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
622 
623 #include "FixedListI.H"
625 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
626 
627 #ifdef NoRepository
628  #include "FixedList.C"
629  #include "FixedListIO.C"
630 #endif
631 
632 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
633 
634 #endif
635 
636 // ************************************************************************* //
const char * cdata_bytes() const noexcept
Return pointer to the underlying array serving as data storage,.
Definition: FixedListI.H:129
void resize(const label n)
Dummy function, to make FixedList consistent with List Any resizing is ignored (Fatal with bad sizing...
Definition: FixedListI.H:314
bool found(const T &val, label pos=0) const
Same as contains()
Definition: FixedList.H:768
bool operator!=(const FixedList< T, N > &list) const
The opposite of the equality operation. Takes linear time.
Definition: FixedList.C:192
std::reverse_iterator< iterator > reverse_iterator
Reverse iterator (non-const access)
Definition: FixedList.H:150
label difference_type
The difference between iterator objects.
Definition: FixedList.H:145
T * pointer
The pointer type for non-const access to value_type items.
Definition: FixedList.H:110
const T & const_reference
The type used for reading from constant value_type objects.
Definition: FixedList.H:125
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:473
static constexpr bool empty() noexcept
Always false since zero-sized FixedList is compile-time disabled.
Definition: FixedList.H:614
void moveLast(const label i)
Move element to the last position.
Definition: FixedList.C:122
bool operator==(const FixedList< T, N > &list) const
Equality operation on FixedLists of the same type.
Definition: FixedList.C:162
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:120
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:323
static std::streamsize byteSize()
Number of contiguous bytes for the list data, runtime FatalError if type is not contiguous.
Definition: FixedList.C:27
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 ...
Definition: FixedListI.H:218
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...
Definition: FixedListI.H:197
iterator end() noexcept
Return an iterator to end traversing the FixedList.
Definition: FixedListI.H:521
T & back() noexcept
Access last element of the list, position [N-1].
Definition: FixedListI.H:183
void checkIndex(const label i) const
Check index is within valid range [0,N)
Definition: FixedListI.H:264
autoPtr< FixedList< T, N > > clone() const
Clone.
Definition: FixedListI.H:103
bool contains(const T &val) const
True if the value is contained in the list.
Definition: FixedListI.H:294
void writeEntry(Ostream &os) const
Write the FixedList with its compound type.
Definition: FixedListIO.C:30
void setSize(const label n)
Dummy function, to make FixedList consistent with List.
Definition: FixedList.H:437
static constexpr unsigned max_size() noexcept
The dimensioned size (template parameter N) of the FixedList.
Definition: FixedList.H:624
T & operator[](const label i)
Return element of FixedList.
Definition: FixedListI.H:394
label size_type
The type to represent the size of a FixedList.
Definition: FixedList.H:140
std::reverse_iterator< const_iterator > const_reverse_iterator
Reverse iterator (const access)
Definition: FixedList.H:155
static constexpr label size() noexcept
Return the number of elements in the FixedList.
Definition: FixedList.H:619
dimensionedScalar pos(const dimensionedScalar &ds)
reverse_iterator rend()
Return reverse_iterator to end reverse traversing the FixedList.
Definition: FixedListI.H:569
const T * cdata() const noexcept
Return pointer to the underlying array serving as data storage.
Definition: FixedListI.H:113
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
const T * const_iterator
Random access iterator for traversing FixedList.
Definition: FixedList.H:135
bool operator>(const FixedList< T, N > &list) const
Compare two FixedLists lexicographically. Takes linear time.
Definition: FixedList.C:199
static std::streamsize size_bytes() noexcept
Number of contiguous bytes for the list data,.
Definition: FixedListI.H:144
void checkStart(const label start) const
Check start is within valid range [0,size)
Definition: FixedListI.H:239
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
Definition: FixedListIO.C:78
Istream & operator>>(Istream &, directionInfo &)
T & first() noexcept
Access first element of the list, position [0] - front()
Definition: FixedList.H:748
void swapFirst(const label i)
Swap element with the first element.
Definition: FixedList.C:134
void operator=(const UList< T > &list)
Assignment to UList operator. Takes linear time.
Definition: FixedListI.H:414
void fill(const T &val)
Assign all entries to the given value.
Definition: FixedListI.H:342
char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage,.
Definition: FixedListI.H:137
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
T * iterator
Random access iterator for traversing FixedList.
Definition: FixedList.H:130
const direction noexcept
Definition: scalarImpl.H:255
T & get() noexcept
Element access using compile-time indexing.
Definition: FixedListI.H:152
void checkSize(const label size) const
Check size is identical to template parameter N.
Definition: FixedListI.H:252
static const FixedList< T, N > & null() noexcept
Return a null FixedList (reference to a nullObject). Read/write access is questionable.
Definition: FixedList.H:164
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.
Definition: FixedListI.H:489
const Vector< label > N(dict.get< Vector< label >>("N"))
const_reverse_iterator crend() const
Return const_reverse_iterator to end reverse traversing FixedList.
Definition: FixedListI.H:585
label rfind(const T &val, label pos=-1) const
Find index of the last occurrence of the value.
Definition: FixedList.C:86
T & last() noexcept
Access last element of the list, position [N-1] - back()
Definition: FixedList.H:758
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:333
T value_type
The value type the FixedList contains.
Definition: FixedList.H:105
label find(const T &val) const
Find index of the first occurrence of the value.
Definition: FixedList.C:42
T & front() noexcept
Access first element of the list, position [0].
Definition: FixedListI.H:169
const T & rcValue(const label i) const
Return reverse circular value (ie, previous value in the list)
Definition: FixedListI.H:225
Hash function class. The default definition is for primitives. Non-primitives used to hash entries on...
Definition: Hash.H:47
const T & fcValue(const label i) const
Return forward circular value (ie, next value in the list)
Definition: FixedListI.H:204
const T * const_pointer
The pointer type for const access to value_type items.
Definition: FixedList.H:115
Istream & readList(Istream &is)
Read from Istream, discarding contents of existing List.
Definition: FixedListIO.C:145
void Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
Exchange contents of lists - see DynamicList::swap().
Definition: DynamicList.H:717
reverse_iterator rbegin()
Return reverse_iterator to begin reverse traversing the FixedList.
Definition: FixedListI.H:545
FOAM_DEPRECATED_FOR(2021-04, "hasher()") Hash()
Definition: FixedList.H:739
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
label n
void moveFirst(const label i)
Move element to the first position.
Definition: FixedList.C:110
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.
Definition: FixedList.C:146
const_iterator cend() const noexcept
Return const_iterator to end traversing the constant FixedList.
Definition: FixedListI.H:537
T * data() noexcept
Return pointer to the underlying array serving as data storage.
Definition: FixedListI.H:121
Number of items before requiring line-breaks in the list output.
Definition: ListPolicy.H:55
const_reverse_iterator crbegin() const
Return const_reverse_iterator to begin reverse traversing FixedList.
Definition: FixedListI.H:561
void transfer(FixedList< T, N > &list)
Transfer by swapping using a move assignment for the content of the individual list elements...
Definition: FixedListI.H:379
bool operator>=(const FixedList< T, N > &list) const
Return true if !(a < b). Takes linear time.
Definition: FixedList.C:213
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:363