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