Loading...
Searching...
No Matches
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-2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::UPtrList
29
30Description
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
69Note
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
74See Also
75 Foam::PtrList
76 Foam::PtrDynList
77
78SourceFiles
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
92namespace Foam
94
95// Forward Declarations
96template<class T> class PtrList;
97template<class T> class UPtrList;
98template<class T> Ostream& operator<<(Ostream& os, const UPtrList<T>& list);
99
100/*---------------------------------------------------------------------------*\
101 Class UPtrList Declaration
102\*---------------------------------------------------------------------------*/
103
104template<class T>
105class UPtrList
106{
107protected:
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;
123
124 // Constructors
125
126 //- Low-level move construct
127 inline explicit UPtrList(Detail::PtrListDetail<T>&& ptrs) noexcept;
128
129
130public:
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
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
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 constexpr UPtrList() noexcept = default;
220
221 //- Construct with specified size and set all entries to \c 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) noexcept;
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
249 // Access
250
251 //- True if the list is empty (ie, size() is zero)
252 inline bool empty() const noexcept;
254 //- The number of entries in the list
255 inline label size() const noexcept;
256
257 //- Size of the underlying storage.
258 inline label capacity() const noexcept;
259
260 //- The number of non-nullptr entries in the list
261 inline label count_nonnull() const noexcept;
262
263 //- Reference to the first element of the list
264 inline T& front();
265
266 //- Reference to first element of the list
267 inline const T& front() const;
269 //- Reference to the last element of the list
270 inline T& back();
271
272 //- Reference to the last element of the list
273 inline const T& back() const;
274
275 //- Return const pointer to element (can be nullptr),
276 //- or nullptr for out-of-range access (ie, \em with bounds checking).
277 // The return value can be tested as a bool.
278 inline const T* test(const label i) const;
279
280 //- Return const pointer to element (can be nullptr),
281 //- or nullptr for out-of-range access (ie, \em with bounds checking).
282 // The return value can be tested as a bool.
283 inline const T* get(const label i) const;
284
285 //- Return pointer to element (can be nullptr),
286 //- or nullptr for out-of-range access (ie, \em with bounds checking).
287 // The return value can be tested as a bool.
288 inline T* get(const label i);
290 //- Return const pointer to element (can be nullptr),
291 //- or nullptr for out-of-range access (ie, \em with bounds checking).
292 // The return value can be tested as a bool.
293 const T* set(const label i) const { return this->get(i); }
294
295
296 // Edit
297
298 //- Set list size to zero.
299 inline void clear();
300
301 //- Nullify all entries. Does not change the list size.
302 inline void free();
303
304 //- Change the size of the list.
305 //- Any new entries are \c nullptr.
306 inline void resize(const label newLen);
307
308 //- Set the list to the given size
309 //- and set \em all entries to \c nullptr.
310 inline void resize_null(const label newLen);
311
312 //- Squeeze out nullptr entries in the list of pointers after which
313 //- any null pointers will be at the end of the list
314 // \return the number of non-null entries
315 label squeezeNull();
316
317 //- Append an element to the end of the list
318 inline void push_back(T* ptr);
320 //- Move append another list to the end of this list.
321 inline void push_back(UPtrList<T>&& other);
322
323 //- Swap content
324 inline void swap(UPtrList<T>& list) noexcept;
325
326 //- Transfer contents into this list and annul the argument
327 inline void transfer(UPtrList<T>& list);
328
329 //- Set element to specified pointer and return the old list element,
330 //- which can be a nullptr.
331 // No-op if the new pointer value is identical to the current content.
332 inline T* set(const label i, T* ptr);
333
334 //- Reorder elements.
335 //- Reordering must be unique (ie, shuffle).
336 // Optionally check that all pointers have been set.
337 void reorder(const labelUList& oldToNew, const bool check = false);
338
339 //- Reorder elements according to new order mapping (newToOld).
340 //- Reordering must be unique (ie, shuffle).
341 // Optionally check that all pointers have been set.
342 void sortOrder(const labelUList& order, const bool check = false);
343
344
345 // Checks
346
347 //- Check and raise FatalError if any nullptr exists in the list
348 inline void checkNonNull() const;
349
350 //- Return const reference to the element at given position.
351 //- FatalError for bounds problem or nullptr.
352 inline const T& at(const label i) const;
353
354 //- Return reference to the element at given position.
355 //- FatalError for bounds problem or nullptr.
356 inline T& at(const label i);
357
359 // Member Operators
360
361 //- Return const reference to the element at given position.
362 //- FatalError for bounds problem or nullptr. Same as at().
363 inline const T& operator[](const label i) const;
364
365 //- Return reference to the element at given position.
366 //- FatalError for bounds problem or nullptr. Same as at().
367 inline T& operator[](const label i);
368
369 //- Deprecated(2022-09) - same as get()
370 // \deprecated(2022-09) - use get(), set() or test() methods
371 FOAM_DEPRECATED_FOR(2022-09, "get(), set() or test() methods")
372 const T* operator()(const label i) const { return this->get(i); }
373
374 //- Copy assignment (shallow copies addresses)
375 inline void operator=(const UPtrList<T>& list);
376
377 //- Move assignment
378 inline void operator=(UPtrList<T>&& list);
380
381 // Writing
382
383 //- Print pointer addresses to Ostream (debugging only)
386 //- Write UPtrList to Ostream, optionally ignoring null entries
387 Ostream& writeList(Ostream& os, const bool trimNull=false) const;
388
389
390 // IOstream Operators
392 //- Write UPtrList to Ostream. Does not ignore null entries
393 friend Ostream& operator<< <T>(Ostream& os, const UPtrList<T>& list);
394
395
396protected:
397
398 // Iterators and helpers
400 //- Internally used base for iterator and const_iterator
401 template<bool Const> class Iterator;
402
403 //- Allow iterator access to internals
404 friend class Iterator<true>;
405
406 //- Allow iterator access to internals
407 friend class Iterator<false>;
408
410 //- The iterator base for UPtrList (internal use only).
411 // Iterates non-nullptr entries.
412
413 template<bool Const>
414 class Iterator
415 {
416 public:
417
418 // Typedefs
420 //- The list container type
421 using list_type =
422 std::conditional_t<Const, const UPtrList<T>, UPtrList<T>>;
423
424
425 protected:
426
427 // Protected Data
428
429 //- The parent being iterated
430 // Uses pointer for default copy/assignment
432
433 //- The position within the list
434 label pos_;
436 // Friendship with UPtrList, for begin constructor
437 friend class UPtrList;
438
439
440 // Protected Constructors
441
442 //- Default construct. Also the same as the end iterator
443 inline constexpr Iterator() noexcept;
444
445 //- Construct begin iterator
446 inline explicit Iterator(list_type* list);
447
448
449 // Protected Member Functions
450
451 //- Increment to the next non-null position
452 inline void increment();
453
454 //- Permit explicit cast to the other (const/non-const) iterator
455 template<bool Any>
456 explicit operator const Iterator<Any>&() const
458 return *reinterpret_cast<const Iterator<Any>*>(this);
459 }
460
461
462 public:
464 // Member Functions/Operators
465
466 //- True if iterator points to a non-null entry
467 bool good() const noexcept { return (list_ && pos_ >= 0); }
468
469 //- The iterator position/index within the list
470 label key() const noexcept { return pos_; }
471
472 //- Compare hash-entry element pointers.
473 // Independent of const/non-const access
474 template<bool Any>
475 bool operator==(const Iterator<Any>& iter) const noexcept
476 {
477 return (pos_ == iter.pos_);
479
480 template<bool Any>
481 bool operator!=(const Iterator<Any>& iter) const noexcept
482 {
483 return (pos_ != iter.pos_);
484 }
485 };
486
487
488public:
489
490 // Iterators
492 //- Forward iterator with non-const access
493 class iterator : public Iterator<false>
494 {
495 public:
496 // using iterator_category = std::forward_iterator_tag;
497 // using difference_type = label;
498 using pointer = T*;
499 using reference = T&;
500
501
502 // Constructors
503
504 //- Default construct - an end iterator
505 constexpr iterator() noexcept = default;
506
507 //- Copy construct from similar access type
508 explicit iterator(const Iterator<false>& iter)
510 Iterator<false>(iter)
511 {}
512
513
514 // Member Functions/Operators
515
516 //- Pointer to the referenced object (failsafe)
517 inline pointer get() const;
518
519 //- Reference to the object
520 inline reference val() const;
521
522 //- Pointer to the referenced object
523 pointer operator->() const { return this->get(); }
524
525 //- Reference to the object
526 reference operator*() const { return this->val(); }
527
528 //- Legacy call operator: reference to the object
529 reference operator()() const { return this->val(); }
530
531 //- Move to the next non-nullptr entry
532 inline iterator& operator++();
533 inline iterator operator++(int);
534 };
535
536
537 //- Forward iterator with const access
538 class const_iterator : public Iterator<true>
539 {
540 public:
541 // using iterator_category = std::forward_iterator_tag;
542 // using difference_type = label;
543 using pointer = const T*;
544 using reference = const T&;
545
546
547 // Generated Methods
548
549 //- Default construct (end iterator)
550 const_iterator() = default;
551
552 //- Copy construct
553 const_iterator(const const_iterator&) = default;
554
555 //- Copy assignment
557
558
559 // Constructors
560
561 //- Copy construct from any access type
562 template<bool Any>
563 const_iterator(const Iterator<Any>& iter)
564 :
565 Iterator<true>(static_cast<const Iterator<Any>&>(iter))
566 {}
567
568 //- Implicit conversion from dissimilar access type
570 :
571 const_iterator(reinterpret_cast<const const_iterator&>(iter))
572 {}
573
575 // Member Functions/Operators
576
577 //- Pointer to the referenced object (failsafe)
578 inline pointer get() const;
579
580 //- Reference to the object
581 inline reference val() const;
582
583 //- Pointer to the referenced object
584 pointer operator->() const { return this->get(); }
585
586 //- Reference to the object
587 reference operator*() const { return this->val(); }
588
589 //- Legacy call operator: reference to the object
590 reference operator()() const { return this->val(); }
591
592 //- Move to the next non-nullptr entry
593 inline const_iterator& operator++();
594 inline const_iterator operator++(int);
595 };
596
597
598 //- Iterator to begin of raw pointers traversal (use with caution)
599 T** begin_ptr() noexcept { return ptrs_.begin(); }
600
601 //- Iterator beyond end of raw pointers traversal (use with caution)
602 T** end_ptr() noexcept { return ptrs_.end(); }
603
605 //- Return iterator to begin traversal of non-nullptr entries.
606 inline iterator begin();
607
608 //- Return iterator beyond end of UPtrList traversal
609 inline iterator end() noexcept;
610
611 //- Return const_iterator to begin traversal of non-nullptr entries.
612 inline const_iterator cbegin() const;
613
614 //- Return const_iterator beyond end of UPtrList traversal
615 inline const_iterator cend() const noexcept;
616
617 //- Return const_iterator to begin traversal of non-nullptr entries.
618 inline const_iterator begin() const;
619
620 //- Return const_iterator beyond end of UPtrList traversal
621 inline const_iterator end() const noexcept;
623
624 // Housekeeping
625
626 //- Alias for resize()
627 void setSize(const label n) { this->resize(n); }
628
629 //- Reference to the first element of the list
630 //FOAM_DEPRECATED_FOR(2022-10, "front()")
631 T& first() { return front(); }
632
633 //- Return reference to first element of the list
634 //FOAM_DEPRECATED_FOR(2022-10, "front()")
635 const T& first() const { return front(); }
637 //- Return reference to the last element of the list
638 //FOAM_DEPRECATED_FOR(2022-10, "back()")
639 T& last() { return back(); }
640
641 //- Return reference to the last element of the list
642 //FOAM_DEPRECATED_FOR(2022-10, "back()")
643 const T& last() const{ return back(); }
644
645 //- Append an element to the end of the list
646 //FOAM_DEPRECATED_FOR(2022-10, "push_back()")
647 void append(T* ptr) { this->push_back(ptr); }
648
649 //- Move append another list to the end of this list.
650 //FOAM_DEPRECATED_FOR(2022-10, "push_back()")
651 void append(UPtrList<T>&& other) { this->push_back(std::move(other)); }
652
653 //- The number of non-nullptr entries in the list
654 FOAM_DEPRECATED_FOR(2024-01, "count_nonnull()")
655 label count() const noexcept { return count_nonnull(); }
657
658
659// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
660
661//- Inplace (stable) sorting of pointer list.
662// This sort function includes null pointer guards and will also sort
663// any null pointers to the end (eg, rubbish that can be truncated)
664template<class T>
665void sort(UPtrList<T>& list);
666
667//- Inplace (stable) sorting of pointer list using given comparator,
668//- which compares objects, not pointers.
669// This sort function includes null pointer guards and will also sort
670// any null pointers to the end (eg, rubbish that can be truncated)
671template<class T, class Compare>
672void sort(UPtrList<T>& list, const Compare& comp);
673
674
675// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
676
677} // End namespace Foam
678
679// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
680
681#include "UPtrListI.H"
682
683// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
684
685#ifdef NoRepository
686 #include "UPtrList.C"
687#endif
688
689// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
691#endif
692
693// ************************************************************************* //
label n
A rudimentary list of pointers used for PtrList, UPtrList, etc. This class is considered implementati...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
Internally used base for iterator and const_iterator.
Definition UPtrList.H:548
bool operator!=(const Iterator< Any > &iter) const noexcept
Definition UPtrList.H:636
label pos_
The position within the list.
Definition UPtrList.H:574
label key() const noexcept
The iterator position/index within the list.
Definition UPtrList.H:622
bool good() const noexcept
True if iterator points to a non-null entry.
Definition UPtrList.H:617
std::conditional_t< Const, const UPtrList< T >, UPtrList< T > > list_type
The list container type.
Definition UPtrList.H:556
constexpr Iterator() noexcept
Default construct. Also the same as the end iterator.
Definition UPtrListI.H:307
list_type * list_
The parent being iterated.
Definition UPtrList.H:569
friend class UPtrList
Definition UPtrList.H:577
bool operator==(const Iterator< Any > &iter) const noexcept
Compare hash-entry element pointers.
Definition UPtrList.H:630
void increment()
Increment to the next non-null position.
Definition UPtrListI.H:333
Forward iterator with const access.
Definition UPtrList.H:714
reference operator()() const
Legacy call operator: reference to the object.
Definition UPtrList.H:785
const_iterator()=default
Default construct (end iterator).
const_iterator(const const_iterator &)=default
Copy construct.
const_iterator & operator=(const const_iterator &)=default
Copy assignment.
const_iterator & operator++()
Move to the next non-nullptr entry.
Definition UPtrListI.H:395
reference operator*() const
Reference to the object.
Definition UPtrList.H:780
const_iterator(const iterator &iter)
Implicit conversion from dissimilar access type.
Definition UPtrList.H:754
const_iterator(const Iterator< Any > &iter)
Copy construct from any access type.
Definition UPtrList.H:746
reference val() const
Reference to the object.
Definition UPtrListI.H:387
pointer get() const
Pointer to the referenced object (failsafe).
Definition UPtrListI.H:380
pointer operator->() const
Pointer to the referenced object.
Definition UPtrList.H:775
Forward iterator with non-const access.
Definition UPtrList.H:651
reference operator()() const
Legacy call operator: reference to the object.
Definition UPtrList.H:700
reference val() const
Reference to the object.
Definition UPtrListI.H:352
iterator & operator++()
Move to the next non-nullptr entry.
Definition UPtrListI.H:360
reference operator*() const
Reference to the object.
Definition UPtrList.H:695
constexpr iterator() noexcept=default
Default construct - an end iterator.
pointer get() const
Pointer to the referenced object (failsafe).
Definition UPtrListI.H:345
pointer operator->() const
Pointer to the referenced object.
Definition UPtrList.H:690
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition UPtrList.H:101
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:289
T & at(const label i)
Return reference to the element at given position. FatalError for bounds problem or nullptr.
Definition UPtrListI.H:165
const const lduInterface * set(const label i) const
Definition UPtrList.H:366
iterator begin()
Return iterator to begin traversal of non-nullptr entries.
Definition UPtrListI.H:416
void append(T *ptr)
Append an element to the end of the list.
Definition UPtrList.H:877
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 & first()
Reference to the first element of the list.
Definition UPtrList.H:849
T ** begin_ptr() noexcept
Iterator to begin of raw pointers traversal (use with caution).
Definition UPtrList.H:798
T value_type
Type of values the list contains.
Definition UPtrList.H:140
void push_back(T *ptr)
Append an element to the end of the list.
Definition UPtrListI.H:265
void reorder(const labelUList &oldToNew, const bool check=false)
Reorder elements. Reordering must be unique (ie, shuffle).
Definition UPtrList.C:62
void operator=(const UPtrList< T > &list)
Copy assignment (shallow copies addresses).
Definition UPtrListI.H:465
Ostream & writeList(Ostream &os, const bool trimNull=false) const
Write UPtrList to Ostream, optionally ignoring null entries.
Definition UPtrList.C:175
Ostream & printAddresses(Ostream &os) const
Print pointer addresses to Ostream (debugging only).
Definition UPtrList.C:167
const const lduInterface * test(const label i) const
void append(UPtrList< T > &&other)
Move append another list to the end of this list.
Definition UPtrList.H:884
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:112
T ** end_ptr() noexcept
Iterator beyond end of raw pointers traversal (use with caution).
Definition UPtrList.H:803
UPtrList(Detail::PtrListDetail< T > &&ptrs) noexcept
Low-level move construct.
Definition UPtrListI.H:48
const T & last() const
Return reference to the last element of the list.
Definition UPtrList.H:870
const_iterator cend() const noexcept
label capacity() const noexcept
const const lduInterface * get(const label i) const
void push_back(UPtrList< T > &&other)
Move append another list to the end of this list.
Definition UPtrListI.H:272
T & reference
A non-const reference to the value_type.
Definition UPtrList.H:145
const T & first() const
Return reference to first element of the list.
Definition UPtrList.H:856
constexpr UPtrList() noexcept=default
Default construct.
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:485
void free()
Nullify all entries. Does not change the list size.
Definition UPtrListI.H:202
label count_nonnull() const noexcept
void resize_null(const label newLen)
Set the list to the given size and set all entries to nullptr.
Definition UPtrListI.H:258
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
void transfer(UPtrList< T > &list)
Transfer contents into this list and annul the argument.
Definition UPtrListI.H:216
Detail::PtrListDetail< const lduInterface > ptrs_
Definition UPtrList.H:109
void clear()
Set list size to zero.
Definition UPtrListI.H:195
void checkNonNull() const
Check and raise FatalError if any nullptr exists in the list.
Definition UPtrListI.H:280
T * set(const label i, T *ptr)
Set element to specified pointer and return the old list element, which can be a nullptr.
Definition UPtrListI.H:182
iterator end() noexcept
Return iterator beyond end of UPtrList traversal.
Definition UPtrListI.H:440
label find_next(label pos) const
The next non-null entry after the specified position.
Definition UPtrListI.H:32
void setAddressableSize(const label n) noexcept
Adjust addressable size.
Definition UPtrListI.H:25
T & operator[](const label i)
Return reference to the element at given position. FatalError for bounds problem or nullptr....
Definition UPtrListI.H:296
label count() const noexcept
Definition UPtrList.H:890
T & last()
Return reference to the last element of the list.
Definition UPtrList.H:863
void resize(const label newLen)
Change the size of the list. Any new entries are nullptr.
Definition UPtrListI.H:251
void swap(UPtrList< T > &list) noexcept
Swap content.
Definition UPtrListI.H:209
const T & const_reference
A const reference to the value_type.
Definition UPtrList.H:150
void operator=(UPtrList< T > &&list)
Move assignment.
Definition UPtrListI.H:472
const volScalarField & T
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
dimensionedScalar pos(const dimensionedScalar &ds)
static void check(const int retVal, const char *what)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
void sort(UList< T > &list)
Sort the list.
Definition UList.C:283
const direction noexcept
Definition scalarImpl.H:265
UList< label > labelUList
A UList of labels.
Definition UList.H:75
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
volScalarField & b
#define FOAM_DEPRECATED_FOR(since, replacement)
Definition stdFoam.H:43
A UPtrList compare binary predicate for reverse sort order.
Definition UPtrList.H:222
bool operator()(const label ai, const label bi) const
Compare dereferenced pointer locations for reverse sort.
Definition UPtrList.H:233
greater(const UPtrList< T > &list)
Definition UPtrList.H:225
const UPtrList< T > & values
Definition UPtrList.H:223
A UPtrList compare binary predicate for normal sort order. Null entries (if any) sort to the end.
Definition UPtrList.H:196
less(const UPtrList< T > &list)
Definition UPtrList.H:199
bool operator()(const label ai, const label bi) const
Compare dereferenced pointer locations for normal sort.
Definition UPtrList.H:207
const UPtrList< T > & values
Definition UPtrList.H:197
A wrapper for a binary comparison of values that interjects pointer dereferencing with null pointer g...
Definition UPtrList.H:174
value_compare(const Compare &cmp)
Definition UPtrList.H:177
bool operator()(const T *const a, const T *const b) const
Compare dereferenced pointers.
Definition UPtrList.H:185