Loading...
Searching...
No Matches
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-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::UList
29
30Description
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
38SourceFiles
39 UList.C
40 UListI.H
41 UListIO.C
42
43\*---------------------------------------------------------------------------*/
44
45#ifndef Foam_UList_H
46#define Foam_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 "stdFoam.H"
54#include "labelRange.H"
55#include "nullObject.H"
56#include "Hash.H"
57#include "ListPolicy.H" // Also includes "contiguous"
58
59#include <vector> // i.e, std::vector
60
61// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62
63namespace Foam
64{
65
66// Forward Declarations
67template<class T> class List;
68template<class T> class SubList;
69template<class T> class UList;
70template<class T> class IndirectList;
71template<class T> class UIndirectList;
72template<class T, class Addr> class IndirectListBase;
74template<class T> Istream& operator>>(Istream&, UList<T>&);
75template<class T> Ostream& operator<<(Ostream&, const UList<T>&);
76
77// Common list types
78typedef UList<bool> boolUList;
79typedef UList<char> charUList;
81
82namespace Expression
83{
84template<class E> class ListExpression;
85template<class T> class ListConstRefWrap;
86}
87
88/*---------------------------------------------------------------------------*\
89 Class UList Declaration
90\*---------------------------------------------------------------------------*/
91
92template<class T>
93class UList
94{
95 // Private Data
96
97 //- Number of elements in UList
98 label size_;
99
100 //- Vector of values of type T
101 T* __restrict__ v_;
102
103
104protected:
105
106 // Protected Member Functions
107
108 //- Set addressed size to be inconsistent with allocated storage.
109 // Use with care
110 inline void setAddressableSize(const label n) noexcept;
111
112 //- Older name for setAddressableSize
113 FOAM_DEPRECATED_FOR(2021-01, "setAddressableSize(label) method")
114 void size(const label n) { this->setAddressableSize(n); }
115
116 //- Write the UList with its compound type
117 void writeEntry(Ostream& os) const;
119 //- Return a validated (start,size) subset range, which means that it
120 //- always addresses a valid section of the list.
121 labelRange validateRange(const labelRange& requestedRange) const;
122
123 //- Assign all entries to the given value
124 // Caution: method name subject to change
125 inline void fill_uniform(const T& val);
126
127 //- Assign all entries to zero
128 // Caution: method name subject to change
130
131
132public:
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;
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;
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
179 // Static Functions
180
181 //- Return a null UList (reference to a nullObject).
182 //- Behaves like an empty UList.
183 static const UList<T>& null() noexcept
184 {
185 return NullObjectRef<UList<T>>();
186 }
187
189 // Public Classes
190
191 //- A list compare binary predicate for normal sort
192 struct less
194 const UList<T>& values;
195
196 less(const UList<T>& list)
197 :
198 values(list)
199 {}
200
201 bool operator()(const label a, const label b) const
202 {
203 return (values[a] < values[b]);
204 }
205 };
206
207 //- A list compare binary predicate for reverse sort
208 struct greater
209 {
210 const UList<T>& values;
211
212 greater(const UList<T>& list)
213 :
214 values(list)
215 {}
216
217 bool operator()(const label a, const label b) const
218 {
219 return (values[b] < values[a]);
220 }
221 };
222
223
224 // Generated Methods
226 //- Copy construct, shallow copy
227 UList(const UList<T>&) noexcept = default;
228
229 //- Move construct, shallow copy
230 UList(UList<T>&&) noexcept = default;
231
232 //- No copy assignment (default: shallow copy)
233 // Assignment may need to be shallow (copy pointer)
234 // or deep (copy elements) depending on context or type of list.
235 // Disallow default assignment and provide separate 'shallowCopy' and
236 // 'deepCopy' member functions.
237 UList<T>& operator=(const UList<T>&) = delete;
239 //- Move assignment, shallow copy.
240 // No ambiguity between shallow or deep copying in this form.
241 UList<T>& operator=(UList<T>&&) noexcept = default;
242
243
244 // Constructors
246 //- Default construct, zero-sized and nullptr
247 inline constexpr UList() noexcept;
248
249 //- Construct from components
250 inline UList(T* __restrict__ ptr, const label len) noexcept;
251
252 //- Move construct from a SubList, shallow copy
255
256 // Member Functions
257
258 // Access
259
260 //- The forward circular index. The next index in the list
261 //- which returns to the first at the end of the list
262 inline label fcIndex(const label i) const noexcept;
264 //- The reverse circular index. The previous index in the list
265 //- which returns to the last at the beginning of the list
266 inline label rcIndex(const label i) const noexcept;
267
268 //- Return forward circular value (ie, next value in the list)
269 inline const T& fcValue(const label i) const;
270
271 //- Return forward circular value (ie, next value in the list)
272 inline T& fcValue(const label i);
273
274 //- Return reverse circular value (ie, previous value in the list)
275 inline const T& rcValue(const label i) const;
276
277 //- Return reverse circular value (ie, previous value in the list)
278 inline T& rcValue(const label i);
279
280 //- Return pointer to the underlying array serving as data storage.
281 inline const T* cdata() const noexcept;
282
283 //- Return pointer to the underlying array serving as data storage.
284 inline T* data() noexcept;
285
286 //- Return pointer to the underlying array serving as data storage,
287 // reinterpreted as byte data
288 // \note Only meaningful for contiguous data
289 inline const char* cdata_bytes() const noexcept;
291 //- Return pointer to the underlying array serving as data storage,
292 // reinterpreted as byte data
293 // \note Only meaningful for contiguous data
294 inline char* data_bytes() noexcept;
295
296 //- Access first element of the list, position [0]
297 inline T& front();
298
299 //- Access first element of the list
300 inline const T& front() const;
301
302 //- Access last element of the list, position [size()-1]
303 inline T& back();
304
305 //- Access last element of the list, position [size()-1]
306 inline const T& back() const;
307
308 //- Number of contiguous bytes for the List data.
309 // \note Only meaningful for contiguous data
310 inline std::streamsize size_bytes() const noexcept;
311
312 //- Number of contiguous bytes for the List data,
313 //- runtime FatalError if type is not contiguous
314 std::streamsize byteSize() const;
316
317 // Check
318
319 //- Check start is within valid range [0,size)
320 inline void checkStart(const label start) const;
321
322 //- Check size is within valid range [0,size]
323 inline void checkSize(const label size) const;
324
325 //- Check that start and length define a valid range
326 inline void checkRange(const label start, const label len) const;
327
328 //- Check index is within valid range [0,size)
329 inline void checkIndex(const label i) const;
330
331 //- True if all entries have identical values, and list is non-empty
332 inline bool uniform() const;
333
334
335 // Search
336
337 //- True if the value is contained in the list.
338 inline bool contains(const T& val) const;
339
340 //- Is the value contained in the list?
341 // \param val The value to search for
342 // \param pos The first position to examine (no-op if -ve)
343 // \param len The length of the search region (-ve until the end)
344 // \return true if found.
345 inline bool contains(const T& val, label pos, label len = -1) const;
346
347 //- Find index of the first occurrence of the value.
348 // \param val The value to search for
349 // \return position in list or -1 if not found.
350 label find(const T& val) const;
351
352 //- Find index of the first occurrence of the value.
353 // \param val The value to search for
354 // \param pos The first position to examine (no-op if -ve)
355 // \param len The length of the search region (-ve until the end)
356 // \return position in list or -1 if not found.
357 label find(const T& val, label pos, label len = -1) const;
358
359 //- Find index of the last occurrence of the value.
360 // Any occurrences after the end pos are ignored.
361 // Linear search.
362 // \return position in list or -1 if not found.
363 label rfind(const T& val, label pos = -1) const;
364
365
366 // Edit
367
368 //- Move element to the first position.
369 void moveFirst(const label i);
371 //- Move element to the last position.
372 void moveLast(const label i);
373
374 //- Swap element with the first element. Fatal on an empty list.
375 void swapFirst(const label i);
376
377 //- Swap element with the last element. Fatal on an empty list.
378 void swapLast(const label i);
379
380
381 // Copy
382
383 //- Copy the pointer and size
384 inline void shallowCopy(T* __restrict__ ptr, const label len) noexcept;
385
386 //- Copy nullptr and zero size
387 inline void shallowCopy(std::nullptr_t) noexcept;
389 //- Copy the pointer and size held by the given UList
390 inline void shallowCopy(const UList<T>& list) noexcept;
391
392 //- Copy elements of the given UList. Sizes must match!
393 void deepCopy(const UList<T>& list);
394
395 //- Copy elements of the given indirect list. Sizes must match!
396 template<class Addr>
397 void deepCopy(const IndirectListBase<T, Addr>& list);
399
400 // Other Access
401
402 //- Return SubList slice (non-const access) - no range checking
403 SubList<T> slice(const label pos, label len = -1);
404
405 //- Return SubList slice (const access) - no range checking
406 const SubList<T> slice(const label pos, label len = -1) const;
407
408 //- Return SubList slice (non-const access) - with range checking.
409 // The range is subsetted with the list size itself to ensure that the
410 // result always addresses a valid section of the list.
412
413 //- Return SubList slice (const access) - with range checking.
414 // The range is subsetted with the list size itself to ensure that the
415 // result always addresses a valid section of the list.
416 const SubList<T> slice(const labelRange& range) const;
417
418
419 // Member Operators
420
421 //- Return element of UList
422 inline T& operator[](const label i);
423
424 //- Return element of constant UList
425 // \note bool specialization adds lazy evaluation so reading an
426 // out-of-range element returns false without ill-effects
427 inline const T& operator[](const label i) const;
428
429 //- Allow cast to a const List<T>&.
430 // \note Marked as "strictly" deprecated.
431 // Currently (2025-04) code still depends on this cast.
432 FOAM_DEPRECATED_STRICTER(2025-04, "dereference as UList, not List?")
433 operator const Foam::List<T>&() const
435 return *reinterpret_cast<const List<T>*>(this);
436 }
437
438 //- Assignment of all entries to the given value
439 inline void operator=(const T& val);
440
441 //- Assignment of all entries to zero
442 inline void operator=(Foam::zero);
443
444
445 // Random access iterator (non-const)
446
447 //- Return an iterator to begin traversing the UList
448 inline iterator begin() noexcept;
449
450 //- Return an iterator to end traversing the UList
451 inline iterator end() noexcept;
452
453 //- Return iterator at offset i from begin,
454 //- clamped to [0,size] range
455 inline iterator begin(const label i) noexcept;
456
458 // Random access iterator (const)
459
460 //- Return const_iterator to begin traversing the constant UList
461 inline const_iterator cbegin() const noexcept;
462
463 //- Return const_iterator to end traversing the constant UList
464 inline const_iterator cend() const noexcept;
466 //- Return const_iterator to begin traversing the constant UList
467 inline const_iterator begin() const noexcept;
468
469 //- Return const_iterator to end traversing the constant UList
470 inline const_iterator end() const noexcept;
471
472 //- Return const_iterator at offset i from begin,
473 //- clamped to [0,size] range
474 inline const_iterator cbegin(const label i) const noexcept;
476 //- Return const_iterator at offset i from begin,
477 //- clamped to [0,size] range
478 inline const_iterator begin(const label i) const noexcept;
479
480
481 // Reverse iterators (non-const)
482
483 //- Return reverse_iterator to begin reverse traversing the UList
485
486 //- Return reverse_iterator to end reverse traversing the UList
487 inline reverse_iterator rend();
488
489
490 // Reverse iterators (const)
491
492 //- Return const_reverse_iterator to begin reverse traversing the UList
493 inline const_reverse_iterator crbegin() const;
494
495 //- Return const_reverse_iterator to end reverse traversing the UList
496 inline const_reverse_iterator crend() const;
498 //- Return const_reverse_iterator to begin reverse traversing the UList
499 inline const_reverse_iterator rbegin() const;
500
501 //- Return const_reverse_iterator to end reverse traversing the UList
503
504
505 // STL member functions
506
507 //- True if List is empty (ie, size() is zero)
508 bool empty() const noexcept { return !size_; }
509
510 //- The number of elements in the container
511 label size() const noexcept { return size_; }
512
513 //- Size of the underlying storage.
514 label capacity() const noexcept { return size_; }
516 //- The size of the largest possible UList
517 static constexpr label max_size() noexcept { return labelMax; }
518
519 //- Swap content with another UList of the same type in constant time
520 inline void swap(UList<T>& list) noexcept;
521
522
523 // STL member operators
524
525 //- Equality operation on ULists of the same type.
526 // Returns true when the ULists are element-wise equal
527 // (using UList::value_type::operator==). Takes linear time
528 bool operator==(const UList<T>& list) const;
529
530 //- The opposite of the equality operation. Takes linear time
531 bool operator!=(const UList<T>& list) const;
532
533 //- Compare two ULists lexicographically. Takes linear time
534 bool operator<(const UList<T>& list) const;
535
536 //- Compare two ULists lexicographically. Takes linear time
537 bool operator>(const UList<T>& list) const;
538
539 //- Return true if !(a > b). Takes linear time
540 bool operator<=(const UList<T>& list) const;
541
542 //- Return true if !(a < b). Takes linear time
543 bool operator>=(const UList<T>& list) const;
545
546 // Reading/writing
547
548 //- Read List contents from Istream.
549 // The List must have the proper size before calling
551
552 //- Write the List as a dictionary entry with keyword
553 void writeEntry(const word& keyword, Ostream& os) const;
554
555 //- Write List, with line-breaks in ASCII when length exceeds shortLen.
556 // Using '0' suppresses line-breaks entirely.
557 Ostream& writeList(Ostream& os, const label shortLen=0) const;
558
559
560 // IOstream Operators
561
562 //- Use the readList() method to read contents from Istream.
563 friend Istream& operator>> <T>
564 (
566 UList<T>& list
567 );
568
569
570 // Special Methods
571
572 //- True if all entries are 'true' or if the list is empty.
573 // \note Method name compatibility with bitSet
574 template
575 <
576 class TypeT = T,
577 class = std::enable_if_t<stdFoam::is_bool_v<TypeT>>
578 >
579 inline bool all() const
580 {
581 return !contains(false);
582 }
583
584 //- True if any entries are 'true'.
585 // \note Method name compatibility with bitSet
586 template
587 <
588 class TypeT = T,
589 class = std::enable_if_t<stdFoam::is_bool_v<TypeT>>
591 inline bool any() const
592 {
593 return contains(true);
594 }
595
596 //- True if no entries are 'true'.
597 // \note Method name compatibility with bitSet
598 template
599 <
600 class TypeT = T,
601 class = std::enable_if_t<stdFoam::is_bool_v<TypeT>>
602 >
603 inline bool none() const
604 {
605 return !contains(true);
606 }
607
608 //- Test \c bool value at specified position,
609 //- always false for out-of-range access.
610 // \note Method name compatibility with bitSet, HashSet
611 template
612 <
613 class TypeT = T,
614 class = std::enable_if_t<stdFoam::is_bool_v<TypeT>>
615 >
616 inline bool test(const label i) const
617 {
618 return (i >= 0 && i < size_ && v_[i]);
619 }
620
621 //- Return \c bool value at specified position,
622 //- always false for out-of-range access.
623 // \note Method name compatibility with bitSet
624 template
625 <
626 class TypeT = T,
627 class = std::enable_if_t<stdFoam::is_bool_v<TypeT>>
628 >
629 inline bool get(const label i) const
631 return (i >= 0 && i < size_ && v_[i]);
632 }
633
634 //- Unset the \c bool entry at specified position,
635 //- always false for out-of-range access.
636 // \return True if value changed and was not out-of-range
637 // \note Method name compatibility with bitSet
638 template
639 <
640 class TypeT = T,
641 class = std::enable_if_t<stdFoam::is_bool_v<TypeT>>
642 >
643 inline bool unset(const label i)
644 {
645 if (i >= 0 && i < size_ && v_[i])
646 {
647 v_[i] = false;
648 return true;
649 }
650 return false;
652
653 //- Return a string_view of the charList. Content is non-modifiable.
654 template
655 <
656 class TypeT = T,
657 class = std::enable_if_t<stdFoam::is_char_v<TypeT>>
658 >
659 inline std::string_view view() const
660 {
661 return std::string_view(v_, size_);
662 }
663
664
665 // Hashing
666
667 //- Hashing functor for UList
668 struct hasher
669 {
670 inline unsigned operator()
671 (
672 const UList<T>& obj,
673 unsigned seed=0
674 ) const
675 {
676 if constexpr (is_contiguous_v<T>)
677 {
678 return Foam::Hasher(obj.cdata(), obj.size_bytes(), seed);
679 }
680 else
681 {
682 Foam::Hash<T> op;
683 for (const T& val : obj)
684 {
685 seed = op(val, seed);
686 }
687 return seed;
689 }
690 };
691
692 //- Deprecated(2021-04) hashing functor. Use hasher()
693 // \deprecated(2021-04) - use hasher() functor
694 template<class Unused=bool>
695 struct Hash : UList<T>::hasher
696 {
697 FOAM_DEPRECATED_FOR(2021-04, "hasher()") Hash() {}
698 };
699
700
701 // Housekeeping
702
703 //- Access first element of the list, position [0]
704 //FOAM_DEPRECATED_FOR(2022-10, "front()")
705 T& first() { return front(); }
707 //- Access first element of the list
708 //FOAM_DEPRECATED_FOR(2022-10, "front()")
709 const T& first() const { return front(); };
710
711 //- Access last element of the list, position [size()-1]
712 //FOAM_DEPRECATED_FOR(2022-10, "back()")
713 T& last() { return back(); }
714
715 //- Access last element of the list, position [size()-1]
716 //FOAM_DEPRECATED_FOR(2022-10, "back()")
717 const T& last() const { return back(); };
718
719 //- Same as contains()
720 bool found(const T& val, label pos = 0) const
722 return this->contains(val, pos);
723 }
724
725
726 // Expression templates
727
728 //- Have unique tag
729 using is_List = void;
730
731 //- Wrap value as expression
732 auto expr() const
733 {
735 }
736
737 //- Assign values from expression
738 template<typename E>
740 {
741 // bypass expr.evaluate to avoid resize ...
742 expr.fill(*this);
743 }
744};
745
746
747// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
748
749//- Read List contents from Istream, list must have the proper size!
750template<class T>
753 return list.readList(is);
754}
755
756
757//- Write List to Ostream, as per UList::writeList() with default length.
758// The default short-length is given by Foam::ListPolicy::short_length
759template<class T>
760Ostream& operator<<(Ostream& os, const UList<T>& list)
761{
763}
764
765//- Write std::vector to Ostream. ASCII only, no line-breaks
766template<class T>
767Ostream& operator<<(Ostream& os, const std::vector<T>& list);
768
769
770// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
771
772//- Fill an identity map with (map[i] == i), works like std::iota().
773// Optionally with an alternative start index, so that (map[i] == i+start)
774void identity(UList<int32_t>& map, int32_t start = 0);
775
776//- Fill an identity map with (map[i] == i), works like std::iota().
777// Optionally with an alternative start index, so that (map[i] == i+start)
778void identity(UList<int64_t>& map, int64_t start = 0);
780//- Sort the list
781template<class T>
782void sort(UList<T>& list);
783
784//- Sort the list with the specified comparator
785template<class T, class Compare>
786void sort(UList<T>& list, const Compare& comp);
788//- Stable sort the list
789template<class T>
790void stableSort(UList<T>& list);
791
792//- Stable sort the list with the specified comparator
793template<class T, class Compare>
794void stableSort(UList<T>& list, const Compare& comp);
795
796//- Randomise the list order
797template<class T>
798void shuffle(UList<T>& list);
799
800//- Reverse the first n elements of the list
801template<class T>
802inline void reverse(UList<T>& list, const label n);
803
804//- Reverse all elements of the list
805template<class T>
806inline void reverse(UList<T>& list);
807
808
809// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
810
811//- Hashing for List data
812template<class T>
813struct Hash<UList<T>> : UList<T>::hasher {};
814
815
816//- Object access operator or list access operator (default is pass-through)
817//- \sa ListListOps::combine()
818template<class T>
819struct accessOp
820{
821 const T& operator()(const T& obj) const { return obj; }
822};
823
824
825//- Test if object is empty, typically using its empty() method.
826template<class T>
827struct emptyOp
828{
829 bool operator()(const T& obj) const { return obj.empty(); }
830};
831
832
833//- Extract size (as label) from an object, typically using its size() method.
834template<class T>
835struct sizeOp
837 label operator()(const T& obj) const { return obj.size(); }
838};
839
840
841// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
842
843} // End namespace Foam
844
845
846// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
847
848// Does not need std::swap or Foam::Swap() specialization
849// since UList is MoveConstructible and MoveAssignable
850
851
852// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
853
854#include "UListI.H"
855
856// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
857
858#ifdef NoRepository
859 #include "UList.C"
860 #include "UListIO.C"
861 #include "IntRangeIO.H"
862 #include "stdVectorIO.H"
863#endif
864
865// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
866
867#endif
869// ************************************************************************* //
Implementation of IO operators for Foam::IntRange.
scalar range
bool found
label n
System bool.
Expression wrap of const reference to UList.
Expression templates for List.
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
A List with indirect addressing.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A non-owning sub-view of a List (allocated or unallocated storage).
Definition SubList.H:61
A List with indirect addressing. Like IndirectList but does not store addressing.
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
void moveLast(const label i)
void operator=(Foam::zero)
Assignment of all entries to zero.
Definition UListI.H:356
void swapLast(const label i)
void shallowCopy(bool *__restrict__ ptr, const label len) noexcept
const_reverse_iterator crbegin() const
bool any() const
True if any entries are 'true'.
Definition UList.H:821
void fill_uniform(const T &val)
Assign all entries to the given value.
Definition UListI.H:46
label difference_type
Definition UList.H:193
T & first()
Access first element of the list, position [0].
Definition UList.H:957
bool found(const T &val, label pos=0) const
Same as contains().
Definition UList.H:983
iterator begin() noexcept
Return an iterator to begin traversing the UList.
Definition UListI.H:410
bool test(const label i) const
Test bool value at specified position, always false for out-of-range access.
Definition UList.H:852
char * data_bytes() noexcept
const_reverse_iterator crend() const
bool operator<(const UList< T > &list) const
Compare two ULists lexicographically. Takes linear time.
Definition UList.C:246
const bool * const_iterator
Definition UList.H:183
void checkIndex(const label i) const
bool none() const
True if no entries are 'true'.
Definition UList.H:836
void swapFirst(const label i)
auto expr() const
Wrap value as expression.
Definition UList.H:999
void deepCopy(const UList< bool > &list)
UList(const UList< T > &) noexcept=default
Copy construct, shallow copy.
void operator=(const T &val)
Assignment of all entries to the given value.
Definition UListI.H:347
bool empty() const noexcept
Definition UList.H:701
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition UList.H:203
bool contains(const bool &val) const
const bool & rcValue(const label i) const
iterator end() noexcept
const_iterator cend() const noexcept
void fill_uniform(Foam::zero)
Assign all entries to zero.
Definition UListI.H:59
std::string_view view() const
Return a string_view of the charList. Content is non-modifiable.
Definition UList.H:903
const bool * cdata() const noexcept
const bool * const_pointer
Definition UList.H:163
label rfind(const bool &val, label pos=-1) const
bool all() const
True if all entries are 'true' or if the list is empty.
Definition UList.H:806
constexpr UList() noexcept
Default construct, zero-sized and nullptr.
Definition UListI.H:28
reverse_iterator rbegin()
void writeEntry(const word &keyword, Ostream &os) const
Write the List as a dictionary entry with keyword.
Definition UListIO.C:77
void swap(UList< T > &list) noexcept
Swap content with another UList of the same type in constant time.
Definition UListI.H:524
const T & last() const
Access last element of the list, position [size()-1].
Definition UList.H:978
static constexpr label max_size() noexcept
The size of the largest possible UList.
Definition UList.H:716
const_iterator cbegin() const noexcept
const bool & fcValue(const label i) const
bool operator>=(const UList< T > &list) const
Return true if !(a < b). Takes linear time.
Definition UList.C:274
void operator=(const Expression::ListExpression< E > &expr)
Assign values from expression.
Definition UList.H:1008
UList(UList< T > &&) noexcept=default
Move construct, shallow copy.
SubList< bool > slice(const label pos, label len=-1)
label rcIndex(const label i) const noexcept
std::reverse_iterator< iterator > reverse_iterator
Definition UList.H:198
bool operator!=(const UList< T > &list) const
The opposite of the equality operation. Takes linear time.
Definition UList.C:239
bool * data() noexcept
const T & first() const
Access first element of the list.
Definition UList.H:964
std::streamsize byteSize() const
bool uniform() const
bool unset(const label i)
Unset the bool entry at specified position, always false for out-of-range access.
Definition UList.H:885
label capacity() const noexcept
Size of the underlying storage.
Definition UList.H:711
void checkSize(const label size) const
const char * cdata_bytes() const noexcept
void writeEntry(Ostream &os) const
Write the UList with its compound type.
Definition UListIO.C:29
static const UList< T > & null() noexcept
Return a null UList (reference to a nullObject). Behaves like an empty UList.
Definition UList.H:225
bool get(const label i) const
Return bool value at specified position, always false for out-of-range access.
Definition UList.H:868
label size() const noexcept
The number of elements in the container.
Definition UList.H:706
reverse_iterator rend()
bool operator>(const UList< T > &list) const
Compare two ULists lexicographically. Takes linear time.
Definition UList.C:260
void moveFirst(const label i)
void size(const label n)
Definition UList.H:118
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
Definition UListIO.C:90
bool operator==(const UList< T > &list) const
Equality operation on ULists of the same type.
Definition UList.C:225
Istream & readList(Istream &is)
Read List contents from Istream.
Definition UListIO.C:192
std::streamsize size_bytes() const noexcept
void checkRange(const label start, const label len) const
void setAddressableSize(const label n) noexcept
Set addressed size to be inconsistent with allocated storage.
Definition UListI.H:517
labelRange validateRange(const labelRange &requestedRange) const
Return a validated (start,size) subset range, which means that it always addresses a valid section of...
Definition UList.C:29
T & last()
Access last element of the list, position [size()-1].
Definition UList.H:971
bool operator<=(const UList< T > &list) const
Return true if !(a > b). Takes linear time.
Definition UList.C:267
UList< T > & operator=(const UList< T > &)=delete
No copy assignment (default: shallow copy).
label find(const bool &val) const
const bool & const_reference
Definition UList.H:173
label fcIndex(const label i) const noexcept
void checkStart(const label start) const
A range or interval of labels defined by a start and a size.
Definition labelRange.H:66
A class for handling words, derived from Foam::string.
Definition word.H:66
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
const volScalarField & T
OBJstream os(runTime.globalPath()/outputName)
A namespace for expression templates.
Namespace for OpenFOAM.
dimensionedScalar pos(const dimensionedScalar &ds)
void shuffle(UList< T > &list)
Randomise the list order.
Definition UList.C:315
const T & NullObjectRef() noexcept
Const reference (of type T) to the nullObject.
Definition nullObject.H:228
void reverse(UList< T > &list, const label n)
Reverse the first n elements of the list.
Definition UListI.H:539
unsigned Hasher(const void *data, size_t len, unsigned seed=0)
Bob Jenkins's 96-bit mixer hashing function (lookup3).
Definition Hasher.C:575
UList< char > charUList
A UList of chars.
Definition UList.H:74
constexpr label labelMax
Definition label.H:55
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Istream & operator>>(Istream &, directionInfo &)
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
void sort(UList< T > &list)
Sort the list.
Definition UList.C:283
UList< bool > boolUList
A UList of bools.
Definition UList.H:73
const direction noexcept
Definition scalarImpl.H:265
constexpr bool is_contiguous_v
The is_contiguous value of Type (after stripping of qualifiers).
Definition contiguous.H:77
UList< label > labelUList
A UList of labels.
Definition UList.H:75
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
void stableSort(UList< T > &list)
Stable sort the list.
Definition UList.C:299
volScalarField & b
Includes some common C++ headers, defines global macros and templates used in multiple places by Open...
#define FOAM_DEPRECATED_FOR(since, replacement)
Definition stdFoam.H:43
#define FOAM_DEPRECATED_STRICTER(since, replacement)
Definition stdFoam.H:56
Hash function class. The default definition is for primitives. Non-primitives used to hash entries on...
Definition Hash.H:48
Number of items before requiring line-breaks in the list output.
Definition ListPolicy.H:56
Deprecated(2021-04) hashing functor. Use hasher().
Definition UList.H:945
FOAM_DEPRECATED_FOR(2021-04, "hasher()") Hash()
Definition UList.H:946
bool operator()(const label a, const label b) const
Definition UList.H:263
const UList< T > & values
Definition UList.H:256
greater(const UList< T > &list)
Definition UList.H:258
Hashing functor for UList.
Definition UList.H:915
bool operator()(const label a, const label b) const
Definition UList.H:245
const UList< T > & values
Definition UList.H:238
less(const UList< T > &list)
Definition UList.H:240
Object access operator or list access operator (default is pass-through).
Definition UList.H:1120
const T & operator()(const T &obj) const
Definition UList.H:1121
Test if object is empty, typically using its empty() method.
Definition UList.H:1130
bool operator()(const T &obj) const
Definition UList.H:1131
Extract size (as label) from an object, typically using its size() method.
Definition UList.H:1140
label operator()(const T &obj) const
Definition UList.H:1141