UList.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-2021 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::UList
29 
30 Description
31  A 1D vector of objects of type <T>, where the size of the vector is
32  known and can be used for subscript bounds checking, etc.
33 
34  Storage is not allocated during construction or use but is supplied to
35  the constructor as an argument. This type of list is particularly useful
36  for lists that refer to parts of existing lists such as SubList.
37 
38 SourceFiles
39  UList.C
40  UListI.H
41  UListIO.C
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #ifndef UList_H
46 #define UList_H
47 
48 #include "bool.H"
49 #include "label.H"
50 #include "uLabel.H"
51 #include "zero.H"
52 #include "one.H"
53 #include "contiguous.H"
54 #include "nullObject.H"
55 #include "stdFoam.H"
56 #include "Hash.H"
57 #include "Swap.H"
58 #include "ListPolicy.H"
59 
60 #include <initializer_list>
61 #include <iterator>
62 #include <type_traits>
63 #include <vector>
64 
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 
67 namespace Foam
68 {
69 
70 // Forward Declarations
71 class Istream;
72 class Ostream;
73 class labelRange;
74 
75 template<class T> class List;
76 template<class T> class SubList;
77 template<class T> class UList;
78 template<class T, class Addr> class IndirectListBase;
79 
80 template<class T> Istream& operator>>(Istream&, UList<T>&);
81 template<class T> Ostream& operator<<(Ostream&, const UList<T>&);
82 
83 // Common list types
86 typedef UList<label> labelUList;
87 
88 
89 /*---------------------------------------------------------------------------*\
90  Class UList Declaration
91 \*---------------------------------------------------------------------------*/
92 
93 template<class T>
94 class UList
95 {
96  // Private Data
97 
98  //- Number of elements in UList
99  label size_;
100 
101  //- Vector of values of type T
102  T* __restrict__ v_;
103 
104 
105 protected:
106 
107  // Protected Member Functions
108 
109  //- Set addressed size to be inconsistent with allocated storage.
110  // Use with care
111  inline void setAddressableSize(const label n) noexcept;
112 
113  //- Older name for setAddressableSize
114  FOAM_DEPRECATED_FOR(2021-01, "setAddressableSize(label) method")
115  void size(const label n) { this->setAddressableSize(n); }
116 
117  //- Write the UList with its compound type
118  void writeEntry(Ostream& os) const;
119 
120  //- Return a validated (start,size) subset range, which means that it
121  //- always addresses a valid section of the list.
122  labelRange validateRange(const labelRange& requestedRange) const;
123 
124  //- No copy assignment (default: shallow copy)
125  //
126  // Assignment may need to be shallow (copy pointer)
127  // or deep (copy elements) depending on context or type of list.
128  // Disallow default assignment and provide separate 'shallowCopy' and
129  // 'deepCopy' member functions.
130  UList<T>& operator=(const UList<T>&) = delete;
131 
132 public:
133 
134  // STL type definitions
135 
136  //- The value type the list contains
137  typedef T value_type;
138 
139  //- The pointer type for non-const access to value_type items
140  typedef T* pointer;
141 
142  //- The pointer type for const access to value_type items
143  typedef const T* const_pointer;
144 
145  //- The type used for storing into value_type objects
146  typedef T& reference;
147 
148  //- The type used for reading from constant value_type objects.
149  typedef const T& const_reference;
150 
151  //- Random access iterator for traversing a UList
152  typedef T* iterator;
153 
154  //- Random access iterator for traversing a UList
155  typedef const T* const_iterator;
156 
157  //- The type to represent the size of a UList
158  typedef label size_type;
159 
160  //- The difference between iterator objects
161  typedef label difference_type;
162 
163  //- Reverse iterator (non-const access)
164  typedef std::reverse_iterator<iterator> reverse_iterator;
165 
166  //- Reverse iterator (const access)
167  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
168 
169 
170  // Related types
171 
172  //- Declare friendship with the List class
173  friend class List<T>;
174 
175  //- Declare friendship with the SubList class
176  friend class SubList<T>;
177 
178 
179  // Static Functions
180 
181  //- Return a UList reference to a nullObject
182  inline static const UList<T>& null();
183 
184 
185  // Public Classes
186 
187  //- A list compare binary predicate for normal sort
188  struct less
189  {
190  const UList<T>& values;
191 
192  less(const UList<T>& list)
193  :
194  values(list)
195  {}
196 
197  bool operator()(const label a, const label b) const
198  {
199  return values[a] < values[b];
200  }
201  };
202 
203  //- A list compare binary predicate for reverse sort
204  struct greater
205  {
206  const UList<T>& values;
207 
208  greater(const UList<T>& list)
209  :
210  values(list)
211  {}
212 
213  bool operator()(const label a, const label b) const
214  {
215  return values[b] < values[a];
216  }
217  };
218 
219 
220  // Generated Methods
221 
222  //- Copy construct
223  UList(const UList<T>&) = default;
224 
225 
226  // Constructors
227 
228  //- Default construct, zero-sized and nullptr
229  inline constexpr UList() noexcept;
230 
231  //- Construct from components
232  inline UList(T* __restrict__ v, const label len) noexcept;
233 
234 
235  // Member Functions
236 
237  // Access
238 
239  //- The forward circular index. The next index in the list
240  //- which returns to the first at the end of the list
241  inline label fcIndex(const label i) const noexcept;
242 
243  //- The reverse circular index. The previous index in the list
244  //- which returns to the last at the beginning of the list
245  inline label rcIndex(const label i) const noexcept;
246 
247  //- Return forward circular value (ie, next value in the list)
248  inline const T& fcValue(const label i) const;
249 
250  //- Return forward circular value (ie, next value in the list)
251  inline T& fcValue(const label i);
252 
253  //- Return reverse circular value (ie, previous value in the list)
254  inline const T& rcValue(const label i) const;
255 
256  //- Return reverse circular value (ie, previous value in the list)
257  inline T& rcValue(const label i);
258 
259  //- Return pointer to the underlying array serving as data storage.
260  inline const T* cdata() const noexcept;
261 
262  //- Return pointer to the underlying array serving as data storage.
263  inline T* data() noexcept;
264 
265  //- Return pointer to the underlying array serving as data storage,
266  // reinterpreted as byte data
267  // \note Only meaningful for contiguous data
268  inline const char* cdata_bytes() const noexcept;
269 
270  //- Return pointer to the underlying array serving as data storage,
271  // reinterpreted as byte data
272  // \note Only meaningful for contiguous data
273  inline char* data_bytes() noexcept;
274 
275  //- Return the first element of the list
276  inline T& first();
277 
278  //- Return first element of the list
279  inline const T& first() const;
280 
281  //- Return the last element of the list
282  inline T& last();
283 
284  //- Return the last element of the list
285  inline const T& last() const;
286 
287  //- Number of contiguous bytes for the List data.
288  // \note Only meaningful for contiguous data
289  inline std::streamsize size_bytes() const noexcept;
290 
291  //- Number of contiguous bytes for the List data,
292  //- runtime FatalError if type is not contiguous
293  std::streamsize byteSize() const;
294 
295 
296  // Check
297 
298  //- Check start is within valid range [0,size)
299  inline void checkStart(const label start) const;
300 
301  //- Check size is within valid range [0,size]
302  inline void checkSize(const label size) const;
303 
304  //- Check that start and length define a valid range
305  inline void checkRange(const label start, const label len) const;
306 
307  //- Check index is within valid range [0,size)
308  inline void checkIndex(const label i) const;
309 
310  //- True if all entries have identical values, and list is non-empty
311  inline bool uniform() const;
312 
313 
314  // Search
315 
316  //- Find index of the first occurrence of the value.
317  // Any occurrences before the start pos are ignored.
318  // Linear search.
319  // \return position in list or -1 if not found.
320  label find(const T& val, label pos = 0) const;
321 
322  //- Find index of the last occurrence of the value.
323  // Any occurrences after the end pos are ignored.
324  // Linear search.
325  // \return position in list or -1 if not found.
326  label rfind(const T& val, label pos = -1) const;
327 
328  //- True if the value if found in the list.
329  // Any occurrences before the start pos are ignored.
330  // Linear search.
331  // \return true if found.
332  inline bool found(const T& val, label pos = 0) const;
333 
334 
335  // Edit
336 
337  //- Move element to the first position.
338  void moveFirst(const label i);
339 
340  //- Move element to the last position.
341  void moveLast(const label i);
342 
343  //- Swap element with the first element. Fatal on an empty list.
344  void swapFirst(const label i);
345 
346  //- Swap element with the last element. Fatal on an empty list.
347  void swapLast(const label i);
348 
349 
350  // Copy
351 
352  //- Copy the pointer and size held by the given UList
353  inline void shallowCopy(const UList<T>& list);
354 
355  //- Copy elements of the given UList. Sizes must match!
356  void deepCopy(const UList<T>& list);
357 
358  //- Copy elements of the given indirect list. Sizes must match!
359  template<class Addr>
360  void deepCopy(const IndirectListBase<T, Addr>& list);
361 
362 
363  // Other Access
364 
365  //- Return SubList slice (non-const access) - no range checking
366  SubList<T> slice(const label pos, label len = -1);
367 
368  //- Return SubList slice (const access) - no range checking
369  const SubList<T> slice(const label pos, label len = -1) const;
370 
371  //- Return SubList slice (non-const access) - with range checking.
372  // The range is subsetted with the list size itself to ensure that the
373  // result always addresses a valid section of the list.
374  SubList<T> slice(const labelRange& range);
375 
376  //- Return SubList slice (const access) - with range checking.
377  // The range is subsetted with the list size itself to ensure that the
378  // result always addresses a valid section of the list.
379  const SubList<T> slice(const labelRange& range) const;
380 
381 
382  // Member Operators
383 
384  //- Return element of UList
385  inline T& operator[](const label i);
386 
387  //- Return element of constant UList
388  // \note bool specialization adds lazy evaluation so reading an
389  // out-of-range element returns false without ill-effects
390  inline const T& operator[](const label i) const;
391 
392  //- Allow cast to a const List<T>&
393  inline operator const Foam::List<T>&() const;
394 
395  //- Assignment of all entries to the given value
396  void operator=(const T& val);
397 
398  //- Assignment of all entries to zero
399  void operator=(const Foam::zero);
400 
401 
402  // Random access iterator (non-const)
403 
404  //- Return an iterator to begin traversing the UList
405  inline iterator begin() noexcept;
406 
407  //- Return an iterator to end traversing the UList
408  inline iterator end() noexcept;
409 
410 
411  // Random access iterator (const)
412 
413  //- Return const_iterator to begin traversing the constant UList
414  inline const_iterator cbegin() const noexcept;
415 
416  //- Return const_iterator to end traversing the constant UList
417  inline const_iterator cend() const noexcept;
418 
419  //- Return const_iterator to begin traversing the constant UList
420  inline const_iterator begin() const noexcept;
421 
422  //- Return const_iterator to end traversing the constant UList
423  inline const_iterator end() const noexcept;
424 
425 
426  // Reverse iterators (non-const)
427 
428  //- Return reverse_iterator to begin reverse traversing the UList
429  inline reverse_iterator rbegin();
430 
431  //- Return reverse_iterator to end reverse traversing the UList
432  inline reverse_iterator rend();
433 
434 
435  // Reverse iterators (const)
436 
437  //- Return const_reverse_iterator to begin reverse traversing the UList
438  inline const_reverse_iterator crbegin() const;
439 
440  //- Return const_reverse_iterator to end reverse traversing the UList
441  inline const_reverse_iterator crend() const;
442 
443  //- Return const_reverse_iterator to begin reverse traversing the UList
444  inline const_reverse_iterator rbegin() const;
445 
446  //- Return const_reverse_iterator to end reverse traversing the UList
447  inline const_reverse_iterator rend() const;
448 
449 
450  // STL member functions
451 
452  //- The number of elements in the UList
453  inline label size() const noexcept;
454 
455  //- True if the UList is empty (ie, size() is zero)
456  inline bool empty() const noexcept;
457 
458  //- The size of the largest possible UList
459  static constexpr label max_size() noexcept { return labelMax; }
460 
461  //- Swap content with another UList of the same type in constant time
462  inline void swap(UList<T>& list);
463 
464 
465  // STL member operators
466 
467  //- Equality operation on ULists of the same type.
468  // Returns true when the ULists are element-wise equal
469  // (using UList::value_type::operator==). Takes linear time
470  bool operator==(const UList<T>& a) const;
471 
472  //- The opposite of the equality operation. Takes linear time
473  bool operator!=(const UList<T>& a) const;
474 
475  //- Compare two ULists lexicographically. Takes linear time
476  bool operator<(const UList<T>& list) const;
477 
478  //- Compare two ULists lexicographically. Takes linear time
479  bool operator>(const UList<T>& a) const;
480 
481  //- Return true if !(a > b). Takes linear time
482  bool operator<=(const UList<T>& a) const;
483 
484  //- Return true if !(a < b). Takes linear time
485  bool operator>=(const UList<T>& a) const;
486 
487 
488  // Reading/writing
489 
490  //- Read List contents from Istream.
491  // The List must have the proper size before calling
492  Istream& readList(Istream& is);
493 
494  //- Write the List as a dictionary entry with keyword
495  void writeEntry(const word& keyword, Ostream& os) const;
496 
497  //- Write List, with line-breaks in ASCII when length exceeds shortLen.
498  // Using '0' suppresses line-breaks entirely.
499  Ostream& writeList(Ostream& os, const label shortLen=0) const;
500 
501 
502  // IOstream Operators
503 
504  //- Use the readList() method to read contents from Istream.
505  friend Istream& operator>> <T>
506  (
507  Istream& os,
508  UList<T>& list
509  );
510 
511 
512  // Special Methods
513 
514  //- A bitSet::test() method for a list of bool
515  //
516  // \return The element value, or false for out-of-range access
517  template<class TypeT = T>
518  typename std::enable_if<std::is_same<bool, TypeT>::value, bool>::type
519  inline test(const label i) const
520  {
521  return (i >= 0 && i < size_ && v_[i]);
522  }
523 
524  //- A bitSet::get() method for a list of bool
525  //
526  // \return The element value, or false for out-of-range access
527  template<class TypeT = T>
528  typename std::enable_if<std::is_same<bool, TypeT>::value, bool>::type
529  inline get(const label i) const
530  {
531  return (i >= 0 && i < size_ && v_[i]);
532  }
533 
534  //- A bitSet::unset() method for a list of bool
535  //
536  // \return True if value changed and was not out-of-range
537  template<class TypeT = T>
538  typename std::enable_if<std::is_same<bool, TypeT>::value, bool>::type
539  inline unset(const label i)
540  {
541  if (i >= 0 && i < size_ && v_[i])
542  {
543  v_[i] = false;
544  return true;
545  }
546  return false;
547  }
548 
549 
550  // Hashing
551 
552  //- Hashing functor for UList
553  struct hasher
554  {
555  inline unsigned operator()
556  (
557  const UList<T>& obj,
558  unsigned seed=0
559  ) const
560  {
562  {
563  return Foam::Hasher(obj.cdata(), obj.size_bytes(), seed);
564  }
565 
566  Foam::Hash<T> op;
567  for (const T& val : obj)
568  {
569  seed = op(val, seed);
570  }
571  return seed;
572  }
573  };
574 
575  //- Deprecated(2021-04) hashing functor. Use hasher()
576  // \deprecated(2021-04) - use hasher() functor
577  template<class Unused=bool>
578  struct Hash : UList<T>::hasher
579  {
580  FOAM_DEPRECATED_FOR(2021-04, "hasher()") Hash() {}
581  };
582 };
583 
584 
585 // * * * * * * * * * * * * Template Specializations * * * * * * * * * * * * //
586 
587 //- Specialized list reading for character lists which always uses
588 //- binary format.
589 template<>
591 
592 //- Specialized writeEntry for character lists which always uses
593 //- binary format.
594 template<>
595 void UList<char>::writeEntry(Ostream& os) const;
596 
597 //- Specialized writeList for character lists which always uses
598 //- binary format.
599 template<>
600 Ostream& UList<char>::writeList(Ostream& os, const label /*unused*/) const;
601 
602 
603 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
604 
605 //- Read List contents from Istream, list must have the proper size!
606 template<class T>
607 Istream& operator>>(Istream& is, UList<T>& list)
608 {
609  return list.readList(is);
610 }
611 
612 
613 //- Write List to Ostream, as per UList::writeList() with default length.
614 // The default short-length is given by Detail::ListPolicy::short_length
615 template<class T>
616 Ostream& operator<<(Ostream& os, const UList<T>& list)
617 {
619 }
620 
621 //- Write std::vector to Ostream. ASCII only, no line-breaks
622 template<class T>
623 Ostream& operator<<(Ostream& os, const std::vector<T>& list);
624 
625 
626 // * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
627 
628 template<class T>
629 void sort(UList<T>& a);
630 
631 template<class T, class Compare>
632 void sort(UList<T>& a, const Compare& comp);
633 
634 template<class T>
635 void stableSort(UList<T>& a);
636 
637 template<class T, class Compare>
638 void stableSort(UList<T>& a, const Compare& comp);
639 
640 template<class T>
641 void shuffle(UList<T>& a);
642 
643 // Reverse the first n elements of the list
644 template<class T>
645 inline void reverse(UList<T>& list, const label n);
646 
647 // Reverse all the elements of the list
648 template<class T>
649 inline void reverse(UList<T>& list);
650 
651 //- Exchange contents of lists - see UList::swap().
652 template<class T>
653 inline void Swap(UList<T>& a, UList<T>& b)
654 {
655  a.swap(b);
656 }
657 
658 
659 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
660 
661 //- Hashing for List data
662 template<class T>
663 struct Hash<UList<T>> : UList<T>::hasher {};
664 
665 
666 //- Object access operator or list access operator.
667 //- \sa ListListOps::combine()
668 template<class T>
669 struct accessOp
670 {
671  const T& operator()(const T& obj) const
672  {
673  return obj; // Default is pass-through
674  }
675 };
676 
677 
678 //- Test if object is empty, typically using its empty() method.
679 template<class T>
680 struct emptyOp
681 {
682  bool operator()(const T& obj) const
683  {
684  return obj.empty();
685  }
686 };
687 
688 
689 //- Extract size (as label) from an object, typically using its size() method.
690 template<class T>
691 struct sizeOp
692 {
693  label operator()(const T& obj) const
694  {
695  return obj.size();
696  }
697 };
698 
699 
700 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
701 
702 } // End namespace Foam
703 
704 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
705 
706 #include "UListI.H"
707 
708 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
709 
710 #ifdef NoRepository
711  #include "UList.C"
712  #include "UListIO.C"
713  #include "stdVectorIO.C"
714 #endif
715 
716 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
717 
718 #endif
719 
720 // ************************************************************************* //
Foam::UList::cdata_bytes
const char * cdata_bytes() const noexcept
Return pointer to the underlying array serving as data storage,.
Definition: UListI.H:244
Foam::UList::writeList
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
Definition: UListIO.C:79
Foam::UList::test
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type test(const label i) const
A bitSet::test() method for a list of bool.
Definition: UList.H:518
Foam::reverse
void reverse(UList< T > &list, const label n)
Definition: UListI.H:449
Foam::UList::operator<
bool operator<(const UList< T > &list) const
Compare two ULists lexicographically. Takes linear time.
Definition: UList.C:329
Foam::UList::less::less
less(const UList< T > &list)
Definition: UList.H:191
Foam::Swap
void Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
Definition: DynamicList.H:429
Foam::UList::cdata
const T * cdata() const noexcept
Return pointer to the underlying array serving as data storage.
Definition: UListI.H:230
Foam::accessOp
Definition: UList.H:668
Foam::UList::rcIndex
label rcIndex(const label i) const noexcept
Definition: UListI.H:67
Foam::labelMax
constexpr label labelMax
Definition: label.H:61
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::UList::validateRange
labelRange validateRange(const labelRange &requestedRange) const
Definition: UList.C:41
Foam::UList::end
iterator end() noexcept
Return an iterator to end traversing the UList.
Definition: UListI.H:350
Foam::UList::first
T & first()
Return the first element of the list.
Definition: UListI.H:202
Foam::UList::const_reference
const typedef T & const_reference
The type used for reading from constant value_type objects.
Definition: UList.H:148
Foam::UList::operator>=
bool operator>=(const UList< T > &a) const
Return true if !(a < b). Takes linear time.
Definition: UList.C:368
Foam::UList::UList
constexpr UList() noexcept
Default construct, zero-sized and nullptr.
Definition: UListI.H:35
Foam::Hasher
unsigned Hasher(const void *data, size_t len, unsigned seed=0)
Bob Jenkins's 96-bit mixer hashing function (lookup3)
Definition: Hasher.C:581
Foam::UList::operator==
bool operator==(const UList< T > &a) const
Equality operation on ULists of the same type.
Definition: UList.C:298
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:54
Foam::UList::operator<=
bool operator<=(const UList< T > &a) const
Return true if !(a > b). Takes linear time.
Definition: UList.C:361
Foam::UList::setAddressableSize
void setAddressableSize(const label n) noexcept
Set addressed size to be inconsistent with allocated storage.
Definition: UListI.H:413
Foam::UList::checkSize
void checkSize(const label size) const
Check size is within valid range [0,size].
Definition: UListI.H:116
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
Foam::UList::size_type
label size_type
The type to represent the size of a UList.
Definition: UList.H:157
Foam::UList::hasher
Hashing functor for UList.
Definition: UList.H:552
Foam::UList::deepCopy
void deepCopy(const UList< T > &list)
Copy elements of the given UList. Sizes must match!
Definition: UList.C:107
ListPolicy.H
Foam::UList::swapFirst
void swapFirst(const label i)
Swap element with the first element. Fatal on an empty list.
Definition: UList.C:81
Foam::UList::data_bytes
char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage,.
Definition: UListI.H:251
Foam::UList::fcIndex
label fcIndex(const label i) const noexcept
Definition: UListI.H:60
Foam::stableSort
void stableSort(UList< T > &a)
Definition: UList.C:275
UListIO.C
Swap.H
Swap arguments as per std::swap, but in Foam namespace.
Foam::UList::rfind
label rfind(const T &val, label pos=-1) const
Find index of the last occurrence of the value.
Definition: UList.C:236
Foam::UList::checkRange
void checkRange(const label start, const label len) const
Check that start and length define a valid range.
Definition: UListI.H:130
Foam::UList::checkStart
void checkStart(const label start) const
Check start is within valid range [0,size)
Definition: UListI.H:102
UList.C
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::uniform
Definition: uniform.H:50
n
label n
Definition: TABSMDCalcMethod2.H:31
one.H
Foam::UList::less::values
const UList< T > & values
Definition: UList.H:189
Foam::UList::begin
iterator begin() noexcept
Return an iterator to begin traversing the UList.
Definition: UListI.H:329
Foam::Hash
Hash function class. The default definition is for primitives. Non-primitives used to hash entries on...
Definition: Hash.H:53
Foam::sizeOp::operator()
label operator()(const T &obj) const
Definition: UList.H:692
Foam::UList::greater
A list compare binary predicate for reverse sort.
Definition: UList.H:203
Foam::UList::cend
const_iterator cend() const noexcept
Return const_iterator to end traversing the constant UList.
Definition: UListI.H:364
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::UList::iterator
T * iterator
Random access iterator for traversing a UList.
Definition: UList.H:151
Foam::UList::last
T & last()
Return the last element of the list.
Definition: UListI.H:216
Foam::UList::swapLast
void swapLast(const label i)
Swap element with the last element. Fatal on an empty list.
Definition: UList.C:93
Foam::UList::moveFirst
void moveFirst(const label i)
Move element to the first position.
Definition: UList.C:57
Foam::UList::reference
T & reference
The type used for storing into value_type objects.
Definition: UList.H:145
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::sort
void sort(UList< T > &a)
Definition: UList.C:261
Foam::Detail::ListPolicy::short_length
Number of items before requiring line-breaks in the list output.
Definition: ListPolicy.H:61
Foam::UList::max_size
static constexpr label max_size() noexcept
The size of the largest possible UList.
Definition: UList.H:458
Foam::UList::operator!=
bool operator!=(const UList< T > &a) const
The opposite of the equality operation. Takes linear time.
Definition: UList.C:322
Foam::labelRange
A range or interval of labels defined by a start and a size.
Definition: labelRange.H:55
Foam::UList::less
A list compare binary predicate for normal sort.
Definition: UList.H:187
bool.H
System bool.
Foam::UList::readList
Istream & readList(Istream &is)
Read List contents from Istream.
Definition: UListIO.C:157
zero.H
Foam::UList::crend
const_reverse_iterator crend() const
Return const_reverse_iterator to end reverse traversing the UList.
Definition: UListI.H:406
Foam::emptyOp::operator()
bool operator()(const T &obj) const
Definition: UList.H:681
Foam::UList::empty
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
Definition: UListI.H:427
os
OBJstream os(runTime.globalPath()/outputName)
Foam::UList::Hash::FOAM_DEPRECATED_FOR
FOAM_DEPRECATED_FOR(2021-04, "hasher()") Hash()
Definition: UList.H:579
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::UList::rend
reverse_iterator rend()
Return reverse_iterator to end reverse traversing the UList.
Definition: UListI.H:392
Foam::UList::fcValue
const T & fcValue(const label i) const
Return forward circular value (ie, next value in the list)
Definition: UListI.H:74
Foam::UList::writeEntry
void writeEntry(Ostream &os) const
Write the UList with its compound type.
Definition: UListIO.C:38
Foam::charUList
UList< char > charUList
A UList of chars.
Definition: UList.H:84
Foam::sizeOp
Extract size (as label) from an object, typically using its size() method.
Definition: UList.H:690
Foam::UList::cbegin
const_iterator cbegin() const noexcept
Return const_iterator to begin traversing the constant UList.
Definition: UListI.H:343
Foam::UList::slice
SubList< T > slice(const label pos, label len=-1)
Return SubList slice (non-const access) - no range checking.
Definition: SubList.H:165
Foam::UList::unset
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type unset(const label i)
A bitSet::unset() method for a list of bool.
Definition: UList.H:538
Foam::UList::shallowCopy
void shallowCopy(const UList< T > &list)
Copy the pointer and size held by the given UList.
Definition: UListI.H:272
Foam::UList::operator>
bool operator>(const UList< T > &a) const
Compare two ULists lexicographically. Takes linear time.
Definition: UList.C:354
Foam::emptyOp
Test if object is empty, typically using its empty() method.
Definition: UList.H:679
Foam::UList::swap
void swap(UList< T > &list)
Swap content with another UList of the same type in constant time.
Definition: UListI.H:434
Foam::boolUList
UList< bool > boolUList
A UList of bools.
Definition: UList.H:83
range
scalar range
Definition: LISASMDCalcMethod1.H:12
Foam::UList::less::operator()
bool operator()(const label a, const label b) const
Definition: UList.H:196
Foam::UList::difference_type
label difference_type
The difference between iterator objects.
Definition: UList.H:160
label.H
Foam::shuffle
void shuffle(UList< T > &a)
Definition: UList.C:289
Foam::UList::rbegin
reverse_iterator rbegin()
Return reverse_iterator to begin reverse traversing the UList.
Definition: UListI.H:371
contiguous.H
Foam::UList::greater::values
const UList< T > & values
Definition: UList.H:205
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::UList::operator=
UList< T > & operator=(const UList< T > &)=delete
No copy assignment (default: shallow copy)
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::UList::Hash
Deprecated(2021-04) hashing functor. Use hasher()
Definition: UList.H:577
stdFoam.H
Foam::UList
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:103
Hash.H
Foam::UList::size
label size() const noexcept
The number of elements in the UList.
Definition: UListI.H:420
Foam::UList::const_pointer
const typedef T * const_pointer
The pointer type for const access to value_type items.
Definition: UList.H:142
Foam::UList::byteSize
std::streamsize byteSize() const
Definition: UList.C:199
Foam::FOAM_DEPRECATED_FOR
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
Definition: NamedEnum.H:69
Foam::UList::const_iterator
const typedef T * const_iterator
Random access iterator for traversing a UList.
Definition: UList.H:154
Foam::UList::greater::operator()
bool operator()(const label a, const label b) const
Definition: UList.H:212
Foam::UList::found
bool found(const T &val, label pos=0) const
True if the value if found in the list.
Definition: UListI.H:265
nullObject.H
Foam::UList::get
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type get(const label i) const
A bitSet::get() method for a list of bool.
Definition: UList.H:528
Foam::UList::const_reverse_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
Reverse iterator (const access)
Definition: UList.H:166
Foam::IndirectListBase
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
Definition: IndirectListBase.H:56
Foam::UList::pointer
T * pointer
The pointer type for non-const access to value_type items.
Definition: UList.H:139
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
stdVectorIO.C
uLabel.H
Foam::labelUList
UList< label > labelUList
A UList of labels.
Definition: UList.H:85
Foam::UList::moveLast
void moveLast(const label i)
Move element to the last position.
Definition: UList.C:69
Foam::UList::find
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
Definition: UList.C:212
Foam::UList::reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
Reverse iterator (non-const access)
Definition: UList.H:163
Foam::UList::checkIndex
void checkIndex(const label i) const
Check index is within valid range [0,size)
Definition: UListI.H:159
Foam::UList::value_type
T value_type
The value type the list contains.
Definition: UList.H:136
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:55
Foam::UList::greater::greater
greater(const UList< T > &list)
Definition: UList.H:207
Foam::UList::size_bytes
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the List data.
Definition: UListI.H:258
UListI.H
Foam::is_contiguous
A template class to specify that a data type can be considered as being contiguous in memory.
Definition: contiguous.H:75
Foam::UList::rcValue
const T & rcValue(const label i) const
Return reverse circular value (ie, previous value in the list)
Definition: UListI.H:88
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62
Foam::UList::crbegin
const_reverse_iterator crbegin() const
Return const_reverse_iterator to begin reverse traversing the UList.
Definition: UListI.H:385
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:177
Foam::accessOp::operator()
const T & operator()(const T &obj) const
Definition: UList.H:670