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