UPtrList.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) 2018-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::UPtrList
29 
30 Description
31  A list of pointers to objects of type <T>, without allocation/deallocation
32  management of the pointers - this is to be done elsewhere.
33  The operator[] returns a reference to the object (not the pointer).
34 
35  The iterators are similar to bitSet in that they skip nullptr entries,
36  and also return a value (like the list operator[] does).
37 
38  When traversing lists, it possible to test the validity directly:
39  \code
40  forAll(interfaces, i)
41  {
42  if (interfaces.test(i))
43  {
44  // Interface is set, do something
45  const auto& intf = interfaces[i];
46  ...
47  }
48  }
49  \endcode
50  The lists can also be traversed with a for-range
51  (in OpenFOAM-v2212 and earlier this would have failed on nullptr entries):
52  \code
53  for (const auto& intf : interfaces)
54  {
55  // Do something
56  ...
57  }
58  \endcode
59 
60  It is also possible to traverse with non-null entries
61  and use key/val access (like HashTable naming):
62  \code
63  forAllConstIters(interfaces, iter)
64  {
65  Info<< "entry " << iter.key() << " : " << iter.val() << nl;
66  }
67  \endcode
68 
69 Note
70  The class definition is such that it contains a list of pointers, but
71  itself does not inherit from a list of pointers since this would
72  wreak havoc later with inheritance resolution.
73 
74 See Also
75  Foam::PtrList
76  Foam::PtrDynList
77 
78 SourceFiles
79  UPtrListI.H
80  UPtrList.C
81 
82 \*---------------------------------------------------------------------------*/
83 
84 #ifndef Foam_UPtrList_H
85 #define Foam_UPtrList_H
86 
87 #include "PtrListDetail.H"
88 #include <iterator>
89 
90 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
91 
92 namespace Foam
93 {
94 
95 // Forward Declarations
96 template<class T> class PtrList;
97 template<class T> class UPtrList;
98 template<class T> Ostream& operator<<(Ostream& os, const UPtrList<T>& list);
99 
100 /*---------------------------------------------------------------------------*\
101  Class UPtrList Declaration
102 \*---------------------------------------------------------------------------*/
103 
104 template<class T>
105 class UPtrList
106 {
107 protected:
108 
109  // Protected Member Data
110 
111  //- The list of pointers
113 
114 
115  // Protected Member Functions
116 
117  //- Adjust addressable size
118  inline void setAddressableSize(const label n) noexcept;
119 
120  //- The next non-null entry after the specified position
121  inline label find_next(label pos) const;
122 
123 
124  // Constructors
125 
126  //- Low-level move construct
127  inline explicit UPtrList(Detail::PtrListDetail<T>&& ptrs);
128 
129 
130 public:
131 
132  // STL type definitions
133 
134  //- Type of values the list contains
135  typedef T value_type;
136 
137  //- A non-const reference to the value_type
138  typedef T& reference;
139 
140  //- A const reference to the value_type
141  typedef const T& const_reference;
142 
143  //- Forward iterator with non-const access
144  class iterator;
146  //- Forward iterator with const access
147  class const_iterator;
148 
149 
150  // Public Classes
151 
152  //- A wrapper for a binary comparison of values that interjects
153  //- pointer dereferencing with null pointer guards.
154  // It will also sort any null pointers to the end
155  // (eg, rubbish that can be truncated)
156  template<class Compare>
157  struct value_compare
158  {
159  const Compare& comp;
160 
161  value_compare(const Compare& cmp)
162  :
163  comp(cmp)
164  {}
165 
166  //- Compare dereferenced pointers
167  bool operator()(const T* const a, const T* const b) const
168  {
169  return (a && b) ? comp(*a, *b) : !b;
170  }
171  };
172 
173  //- A UPtrList compare binary predicate for normal sort order.
174  //- Null entries (if any) sort to the end.
175  struct less
176  {
178 
179  less(const UPtrList<T>& list)
180  :
181  values(list)
182  {}
183 
184  //- Compare dereferenced pointer locations for normal sort.
185  bool operator()(const label ai, const label bi) const
186  {
187  const T* const a = values.get(ai);
188  const T* const b = values.get(bi);
189 
190  return (a && b) ? (*a < *b) : !b;
191  }
192  };
193 
194  //- A UPtrList compare binary predicate for reverse sort order.
195  // Null entries (if any) sort to the end.
196  struct greater
197  {
198  const UPtrList<T>& values;
200  greater(const UPtrList<T>& list)
201  :
202  values(list)
203  {}
204 
205  //- Compare dereferenced pointer locations for reverse sort
206  bool operator()(const label ai, const label bi) const
207  {
208  const T* const a = values.get(ai);
209  const T* const b = values.get(bi);
210 
211  return (a && b) ? (*b < *a) : !a;
212  }
213  };
214 
215 
216  // Constructors
217 
218  //- Default construct
219  inline constexpr UPtrList() noexcept;
220 
221  //- Construct with specified size, each element initialized to nullptr
222  inline explicit UPtrList(const label len);
224  //- Copy construct (shallow copies addresses)
225  inline UPtrList(const UPtrList<T>& list);
226 
227  //- Move construct
228  inline UPtrList(UPtrList<T>&& list);
229 
230  //- Construct as shallow copy or re-use as specified
231  inline UPtrList(UPtrList<T>& list, bool reuse);
232 
233  //- Shallow copy from PtrList.
234  // The argument is non-const to reflect that the UPtrList can change
235  // the values (not the addresses) within the original list.
236  explicit UPtrList(PtrList<T>& list);
237 
238  //- Construct from UList of pointers (shallow copy)
239  inline explicit UPtrList(const UList<T*>& list);
240 
241  //- Construct from UList, taking the address of each list element
242  // The argument is non-const to reflect that the UPtrList can change
243  // the values of the original list.
244  inline explicit UPtrList(UList<T>& list);
245 
246 
247  // Member Functions
248 
249  // Access
250 
251  //- True if the list is empty (ie, size() is zero)
252  inline bool empty() const noexcept;
253 
254  //- The number of entries in the list
255  inline label size() const noexcept;
256 
257  //- The number of non-null entries in the list
258  inline label count() const noexcept;
259 
260  //- Reference to the first element of the list
261  inline T& front();
262 
263  //- Reference to first element of the list
264  inline const T& front() const;
265 
266  //- Reference to the last element of the list
267  inline T& back();
268 
269  //- Reference to the last element of the list
270  inline const T& back() const;
271 
272  //- Return const pointer to element (can be nullptr),
273  //- or nullptr for out-of-range access (ie, \em with bounds checking).
274  // The return value can be tested as a bool.
275  inline const T* test(const label i) const;
276 
277  //- Return const pointer to element (can be nullptr),
278  //- or nullptr for out-of-range access (ie, \em with bounds checking).
279  // The return value can be tested as a bool.
280  inline const T* get(const label i) const;
281 
282  //- Return pointer to element (can be nullptr),
283  //- or nullptr for out-of-range access (ie, \em with bounds checking).
284  // The return value can be tested as a bool.
285  inline T* get(const label i);
286 
287  //- Return const pointer to element (can be nullptr),
288  //- or nullptr for out-of-range access (ie, \em with bounds checking).
289  // The return value can be tested as a bool.
290  const T* set(const label i) const { return this->get(i); }
291 
292 
293  // Edit
294 
295  //- Set list size to zero.
296  inline void clear();
297 
298  //- Nullify all entries. Does not change the list size.
299  inline void free();
300 
301  //- Change the size of the list.
302  // New entries are initialized to nullptr.
303  inline void resize(const label newLen);
304 
305  //- Squeeze out nullptr entries in the list of pointers after which
306  //- any null pointers will be at the end of the list
307  // \return the number of non-null entries
308  label squeezeNull();
309 
310  //- Reduce addressable list size to ignore any trailing null pointers.
311  // The reduces the effective list length without reallocation
312  void trimTrailingNull();
313 
314  //- Append an element to the end of the list
315  inline void push_back(T* ptr);
316 
317  //- Move append another list to the end of this list.
318  inline void push_back(UPtrList<T>&& other);
319 
320  //- Swap content
321  inline void swap(UPtrList<T>& list);
322 
323  //- Transfer contents into this list and annul the argument
324  inline void transfer(UPtrList<T>& list);
325 
326  //- Set element to specified pointer and return the old list element,
327  //- which can be a nullptr.
328  // No-op if the new pointer value is identical to the current content.
329  inline T* set(const label i, T* ptr);
330 
331  //- Reorder elements.
332  //- Reordering must be unique (ie, shuffle).
333  // Optionally check that all pointers have been set.
334  void reorder(const labelUList& oldToNew, const bool check = false);
335 
336  //- Reorder elements according to new order mapping (newToOld).
337  //- Reordering must be unique (ie, shuffle).
338  // Optionally check that all pointers have been set.
339  void sortOrder(const labelUList& order, const bool check = false);
340 
341 
342  // Checks
343 
344  //- Check and raise FatalError if any nullptr exists in the list
345  inline void checkNonNull() const;
346 
347  //- Return const reference to the element at given position.
348  //- FatalError for bounds problem or nullptr.
349  inline const T& at(const label i) const;
350 
351  //- Return reference to the element at given position.
352  //- FatalError for bounds problem or nullptr.
353  inline T& at(const label i);
354 
355 
356  // Member Operators
357 
358  //- Return const reference to the element at given position.
359  //- FatalError for bounds problem or nullptr. Same as at().
360  inline const T& operator[](const label i) const;
362  //- Return reference to the element at given position.
363  //- FatalError for bounds problem or nullptr. Same as at().
364  inline T& operator[](const label i);
365 
366  //- Deprecated(2022-09) - same as get()
367  // \deprecated(2022-09) - use get(), set() or test() methods
368  FOAM_DEPRECATED_FOR(2022-09, "get(), set() or test() methods")
369  const T* operator()(const label i) const { return this->get(i); }
370 
371  //- Copy assignment (shallow copies addresses)
372  inline void operator=(const UPtrList<T>& list);
373 
374  //- Move assignment
375  inline void operator=(UPtrList<T>&& list);
376 
377 
378  // IOstream Operators
379 
380  //- Write UPtrList to Ostream
381  friend Ostream& operator<< <T>(Ostream& os, const UPtrList<T>& list);
382 
383 
384 protected:
385 
386  // Iterators and helpers
387 
388  //- Internally used base for iterator and const_iterator
389  template<bool Const> class Iterator;
390 
391  //- Allow iterator access to internals
392  friend class Iterator<true>;
393 
394  //- Allow iterator access to internals
395  friend class Iterator<false>;
396 
397 
398  //- The iterator base for UPtrList (internal use only).
399  // Iterates non-nullptr entries.
400 
401  template<bool Const>
402  class Iterator
403  {
404  public:
405 
406  // Typedefs
407 
408  //- The list container type
409  using list_type = typename std::conditional
410  <
411  Const,
412  const UPtrList<T>,
414  >::type;
415 
416 
417  protected:
418 
419  // Protected Data
420 
421  //- The parent being iterated
422  // Uses pointer for default copy/assignment
423  list_type* list_;
424 
425  //- The position within the list
426  label pos_;
427 
428  // Friendship with UPtrList, for begin constructor
429  friend class UPtrList;
430 
431 
432  // Protected Constructors
433 
434  //- Default construct. Also the same as the end iterator
435  inline constexpr Iterator() noexcept;
436 
437  //- Construct begin iterator
438  inline explicit Iterator(list_type* list);
439 
440 
441  // Protected Member Functions
442 
443  //- Increment to the next non-null position
444  inline void increment();
445 
446  //- Permit explicit cast to the other (const/non-const) iterator
447  template<bool Any>
448  explicit operator const Iterator<Any>&() const
449  {
450  return *reinterpret_cast<const Iterator<Any>*>(this);
451  }
452 
453 
454  public:
455 
456  // Member Functions/Operators
457 
458  //- True if iterator points to a non-null entry
459  bool good() const noexcept { return (list_ && pos_ >= 0); }
460 
461  //- The iterator position/index within the list
462  label key() const noexcept { return pos_; }
463 
464  //- Compare hash-entry element pointers.
465  // Independent of const/non-const access
466  template<bool Any>
467  bool operator==(const Iterator<Any>& iter) const noexcept
468  {
469  return (pos_ == iter.pos_);
470  }
471 
472  template<bool Any>
473  bool operator!=(const Iterator<Any>& iter) const noexcept
474  {
475  return (pos_ != iter.pos_);
476  }
477  };
478 
479 
480 public:
481 
482  // Iterators
483 
484  //- Forward iterator with non-const access
485  class iterator : public Iterator<false>
486  {
487  public:
488  // using iterator_category = std::forward_iterator_tag;
489  // using difference_type = label;
490  using pointer = T*;
491  using reference = T&;
492 
493 
494  // Constructors
495 
496  //- Default construct - an end iterator
497  constexpr iterator() noexcept = default;
498 
499  //- Copy construct from similar access type
500  explicit iterator(const Iterator<false>& iter)
501  :
502  Iterator<false>(iter)
503  {}
504 
505 
506  // Member Functions/Operators
507 
508  //- Pointer to the referenced object (failsafe)
509  inline pointer get() const;
510 
511  //- Reference to the object
512  inline reference val() const;
513 
514  //- Pointer to the referenced object
515  pointer operator->() const { return this->get(); }
516 
517  //- Reference to the object
518  reference operator*() const { return this->val(); }
519 
520  //- Legacy call operator: reference to the object
521  reference operator()() const { return this->val(); }
522 
523  //- Move to the next non-nullptr entry
524  inline iterator& operator++();
525  inline iterator operator++(int);
526  };
527 
528 
529  //- Forward iterator with const access
530  class const_iterator : public Iterator<true>
531  {
532  public:
533  // using iterator_category = std::forward_iterator_tag;
534  // using difference_type = label;
535  using pointer = const T*;
536  using reference = const T&;
537 
538 
539  // Generated Methods
540 
541  //- Default construct (end iterator)
542  const_iterator() = default;
543 
544  //- Copy construct
545  const_iterator(const const_iterator&) = default;
546 
547  //- Copy assignment
548  const_iterator& operator=(const const_iterator&) = default;
549 
550 
551  // Constructors
552 
553  //- Copy construct from any access type
554  template<bool Any>
555  const_iterator(const Iterator<Any>& iter)
556  :
557  Iterator<true>(static_cast<const Iterator<Any>&>(iter))
558  {}
559 
560  //- Implicit conversion from dissimilar access type
561  const_iterator(const iterator& iter)
562  :
563  const_iterator(reinterpret_cast<const const_iterator&>(iter))
564  {}
566 
567  // Member Functions/Operators
568 
569  //- Pointer to the referenced object (failsafe)
570  inline pointer get() const;
571 
572  //- Reference to the object
573  inline reference val() const;
574 
575  //- Pointer to the referenced object
576  pointer operator->() const { return this->get(); }
577 
578  //- Reference to the object
579  reference operator*() const { return this->val(); }
580 
581  //- Legacy call operator: reference to the object
582  reference operator()() const { return this->val(); }
583 
584  //- Move to the next non-nullptr entry
585  inline const_iterator& operator++();
586  inline const_iterator operator++(int);
587  };
588 
589 
590  //- Iterator to begin of raw pointers traversal (use with caution)
591  T** begin_ptr() noexcept { return ptrs_.begin(); }
593  //- Iterator beyond end of raw pointers traversal (use with caution)
594  T** end_ptr() noexcept { return ptrs_.end(); }
595 
596 
597  //- Return iterator to begin traversal of non-nullptr entries.
598  inline iterator begin();
599 
600  //- Return iterator beyond end of UPtrList traversal
601  inline iterator end() noexcept;
602 
603  //- Return const_iterator to begin traversal of non-nullptr entries.
604  inline const_iterator cbegin() const;
606  //- Return const_iterator beyond end of UPtrList traversal
607  inline const_iterator cend() const noexcept;
608 
609  //- Return const_iterator to begin traversal of non-nullptr entries.
610  inline const_iterator begin() const;
611 
612  //- Return const_iterator beyond end of UPtrList traversal
613  inline const_iterator end() const noexcept;
614 
615 
616  // Housekeeping
617 
618  //- Alias for resize()
619  void setSize(const label n) { this->resize(n); }
620 
621  //- Reference to the first element of the list
622  //FOAM_DEPRECATED_FOR(2022-10, "front()")
623  T& first() { return front(); }
625  //- Return reference to first element of the list
626  //FOAM_DEPRECATED_FOR(2022-10, "front()")
627  const T& first() const { return front(); }
628 
629  //- Return reference to the last element of the list
630  //FOAM_DEPRECATED_FOR(2022-10, "back()")
631  T& last() { return back(); }
632 
633  //- Return reference to the last element of the list
634  //FOAM_DEPRECATED_FOR(2022-10, "back()")
635  const T& last() const{ return back(); }
636 
637  //- Append an element to the end of the list
638  //FOAM_DEPRECATED_FOR(2022-10, "push_back()")
639  void append(T* ptr) { this->push_back(ptr); }
640 
641  //- Move append another list to the end of this list.
642  //FOAM_DEPRECATED_FOR(2022-10, "push_back()")
643  void append(UPtrList<T>&& other) { this->push_back(std::move(other)); }
644 };
645 
646 
647 // * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
648 
649 //- Inplace (stable) sorting of pointer list.
650 // This sort function includes null pointer guards and will also sort
651 // any null pointers to the end (eg, rubbish that can be truncated)
652 template<class T>
653 void sort(UPtrList<T>& list);
654 
655 //- Inplace (stable) sorting of pointer list using given comparator,
656 //- which compares objects, not pointers.
657 // This sort function includes null pointer guards and will also sort
658 // any null pointers to the end (eg, rubbish that can be truncated)
659 template<class T, class Compare>
660 void sort(UPtrList<T>& list, const Compare& comp);
661 
662 
663 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
664 
665 } // End namespace Foam
666 
667 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
668 
669 #include "UPtrListI.H"
670 
671 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
672 
673 #ifdef NoRepository
674  #include "UPtrList.C"
675 #endif
676 
677 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
679 #endif
680 
681 // ************************************************************************* //
reference val() const
Reference to the object.
Definition: UPtrListI.H:380
list_type * list_
The parent being iterated.
Definition: UPtrList.H:557
const T & operator[](const label i) const
Return const reference to the element at given position. FatalError for bounds problem or nullptr...
Definition: UPtrListI.H:282
const T * test(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
Definition: UPtrListI.H:127
label key() const noexcept
The iterator position/index within the list.
Definition: UPtrList.H:610
T & last()
Return reference to the last element of the list.
Definition: UPtrList.H:851
T & reference
A non-const reference to the value_type.
Definition: UPtrList.H:145
constexpr iterator() noexcept=default
Default construct - an end iterator.
constexpr UPtrList() noexcept
Default construct.
Definition: UPtrListI.H:41
typename std::conditional< Const, const UPtrList< T >, UPtrList< T > >::type list_type
The list container type.
Definition: UPtrList.H:545
T & back()
Reference to the last element of the list.
Definition: UPtrListI.H:237
void append(T *ptr)
Append an element to the end of the list.
Definition: UPtrList.H:865
iterator & operator++()
Move to the next non-nullptr entry.
Definition: UPtrListI.H:353
A rudimentary list of pointers used for PtrList, UPtrList, etc. This class is considered implementati...
Definition: PtrListDetail.H:57
FOAM_DEPRECATED_FOR(2022-09, "get(), set() or test() methods") const T *operator()(const label i) const
Deprecated(2022-09) - same as get()
Definition: UPtrList.H:482
void reorder(const labelUList &oldToNew, const bool check=false)
Reorder elements. Reordering must be unique (ie, shuffle).
Definition: UPtrList.C:79
const_iterator & operator++()
Move to the next non-nullptr entry.
Definition: UPtrListI.H:388
T ** begin_ptr() noexcept
Iterator to begin of raw pointers traversal (use with caution)
Definition: UPtrList.H:786
T & first()
Reference to the first element of the list.
Definition: UPtrList.H:837
const T * get(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
Definition: UPtrListI.H:134
const T & at(const label i) const
Return const reference to the element at given position. FatalError for bounds problem or nullptr...
Definition: UPtrListI.H:148
T & front()
Reference to the first element of the list.
Definition: UPtrListI.H:223
const UPtrList< T > & values
Definition: UPtrList.H:197
reference operator()() const
Legacy call operator: reference to the object.
Definition: UPtrList.H:773
Forward iterator with const access.
Definition: UPtrList.H:701
greater(const UPtrList< T > &list)
Definition: UPtrList.H:225
label pos_
The position within the list.
Definition: UPtrList.H:562
Forward iterator with non-const access.
Definition: UPtrList.H:638
Internally used base for iterator and const_iterator.
Definition: UPtrList.H:511
dimensionedScalar pos(const dimensionedScalar &ds)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
void free()
Nullify all entries. Does not change the list size.
Definition: UPtrListI.H:202
constexpr Iterator() noexcept
Default construct. Also the same as the end iterator.
Definition: UPtrListI.H:300
T value_type
Type of values the list contains.
Definition: UPtrList.H:140
reference operator*() const
Reference to the object.
Definition: UPtrList.H:683
const T & const_reference
A const reference to the value_type.
Definition: UPtrList.H:150
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
void push_back(T *ptr)
Append an element to the end of the list.
Definition: UPtrListI.H:258
less(const UPtrList< T > &list)
Definition: UPtrList.H:199
void sort(UList< T > &list)
Sort the list.
Definition: UList.C:348
pointer operator->() const
Pointer to the referenced object.
Definition: UPtrList.H:678
label size() const noexcept
The number of entries in the list.
Definition: UPtrListI.H:113
void checkNonNull() const
Check and raise FatalError if any nullptr exists in the list.
Definition: UPtrListI.H:273
void transfer(UPtrList< T > &list)
Transfer contents into this list and annul the argument.
Definition: UPtrListI.H:216
reference val() const
Reference to the object.
Definition: UPtrListI.H:345
bool operator()(const label ai, const label bi) const
Compare dereferenced pointer locations for reverse sort.
Definition: UPtrList.H:233
T ** end_ptr() noexcept
Iterator beyond end of raw pointers traversal (use with caution)
Definition: UPtrList.H:791
friend Ostream & operator(Ostream &os, const UPtrList< T > &list)
Write UPtrList to Ostream.
void resize(const label newLen)
Change the size of the list.
Definition: UPtrListI.H:251
void swap(UPtrList< T > &list)
Swap content.
Definition: UPtrListI.H:209
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:100
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:99
bool operator==(const Iterator< Any > &iter) const noexcept
Compare hash-entry element pointers.
Definition: UPtrList.H:618
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
const direction noexcept
Definition: Scalar.H:258
OBJstream os(runTime.globalPath()/outputName)
bool operator()(const T *const a, const T *const b) const
Compare dereferenced pointers.
Definition: UPtrList.H:185
static void check(const int retVal, const char *what)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
void trimTrailingNull()
Reduce addressable list size to ignore any trailing null pointers.
Definition: UPtrList.C:62
void operator=(const UPtrList< T > &list)
Copy assignment (shallow copies addresses)
Definition: UPtrListI.H:458
const UPtrList< T > & values
Definition: UPtrList.H:223
label find_next(label pos) const
The next non-null entry after the specified position.
Definition: UPtrListI.H:32
bool empty() const noexcept
True if the list is empty (ie, size() is zero)
Definition: UPtrListI.H:106
iterator begin()
Return iterator to begin traversal of non-nullptr entries.
Definition: UPtrListI.H:409
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
iterator end() noexcept
Return iterator beyond end of UPtrList traversal.
Definition: UPtrListI.H:433
reference operator()() const
Legacy call operator: reference to the object.
Definition: UPtrList.H:688
label n
const_iterator cend() const noexcept
Return const_iterator beyond end of UPtrList traversal.
Definition: UPtrListI.H:449
bool good() const noexcept
True if iterator points to a non-null entry.
Definition: UPtrList.H:605
reference operator*() const
Reference to the object.
Definition: UPtrList.H:768
const_iterator & operator=(const const_iterator &)=default
Copy assignment.
pointer operator->() const
Pointer to the referenced object.
Definition: UPtrList.H:763
void clear()
Set list size to zero.
Definition: UPtrListI.H:195
void setSize(const label n)
Alias for resize()
Definition: UPtrList.H:830
const_iterator cbegin() const
Return const_iterator to begin traversal of non-nullptr entries.
Definition: UPtrListI.H:425
bool operator!=(const Iterator< Any > &iter) const noexcept
Definition: UPtrList.H:624
label squeezeNull()
Squeeze out nullptr entries in the list of pointers after which any null pointers will be at the end ...
Definition: UPtrList.C:38
Detail::PtrListDetail< T > ptrs_
The list of pointers.
Definition: UPtrList.H:109
void setAddressableSize(const label n) noexcept
Adjust addressable size.
Definition: UPtrListI.H:25
A UPtrList compare binary predicate for reverse sort order.
Definition: UPtrList.H:221
label count() const noexcept
The number of non-null entries in the list.
Definition: UPtrListI.H:120
Namespace for OpenFOAM.
value_compare(const Compare &cmp)
Definition: UPtrList.H:177
friend class Iterator< false >
Allow iterator access to internals.
Definition: UPtrList.H:521
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
Definition: UPtrList.H:361
const_iterator()=default
Default construct (end iterator)
void sortOrder(const labelUList &order, const bool check=false)
Reorder elements according to new order mapping (newToOld). Reordering must be unique (ie...
Definition: UPtrList.C:128
void increment()
Increment to the next non-null position.
Definition: UPtrListI.H:326
A UPtrList compare binary predicate for normal sort order. Null entries (if any) sort to the end...
Definition: UPtrList.H:195