Loading...
Searching...
No Matches
PackedList.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::PackedList
29
30Description
31 A dynamic list of packed unsigned integers, with the number of bits
32 per item specified by the <Width> template parameter.
33
34 Resizing is similar to DynamicList so that clear() and resize() affect
35 the addressed size, but not the allocated size. The reserve() and
36 setCapacity() methods can be used to influence the allocation.
37
38Note
39 In a const context, the '[]' operator simply returns the stored value,
40 with out-of-range elements returned as zero.
41
42 In a non-const context, the '[]' operator returns a reference to an
43 existing value. When accessing out-of-range elements, some caution
44 is required to ensure that the const version of the [] operator is actually
45 being called.
46 The get() method is functionally identical the the '[]' operator, but
47 is always const access.
48
49 The set() and unset() methods return a bool if the value changed.
50
51 With const access, the get() method and 'operator[]' are identical.
52 With non-const access, the 'operator[]' may be marginally slower get().
53
54 The set() method may be marginally faster than using the 'operator[]'
55 supports auto-vivification and also returns a bool if the value changed,
56 which can be useful for branching on changed values.
57
58 \code
59 list.set(5, 4);
60 changed = list.set(5, 8);
61 if (changed) ...
62 \endcode
63
64 In a const context, reading an out-of-range element returns zero without
65 affecting the list size.
66 For example,
67 \code
68 list.resize(4);
69 Info<< list.get(10) << "\n"; // print zero, but doesn't adjust list
70 list.set(8); // auto-vivify
71 \endcode
72
73 Also note that all unused internal storage elements are guaranteed to
74 always be bit-wise zero. This property must not be violated by any
75 inheriting classes.
76
77Note
78 Iterators for this class have been intentionally removed, for performance
79 reasons.
80
81See also
82 Foam::BitOps
83 Foam::DynamicList
84
85SourceFiles
86 PackedList.C
87 PackedListCore.C
88 PackedListI.H
89 PackedListIO.C
90
91\*---------------------------------------------------------------------------*/
92
93#ifndef Foam_PackedList_H
94#define Foam_PackedList_H
95
96#include "className.H"
97#include "BitOps.H"
98#include "labelList.H"
99#include "IndirectListBase.H"
100#include "InfoProxy.H"
101
102#include <type_traits>
103
104// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
105
106namespace Foam
107{
109// Forward Declarations
110template<unsigned Width> class PackedList;
111
112template<unsigned Width>
115template<unsigned Width>
117
118template<unsigned Width>
120
121
122/*---------------------------------------------------------------------------*\
123 Class Detail::PackedListCore Declaration
124\*---------------------------------------------------------------------------*/
125
126namespace Detail
128
129//- Template-invariant parts for PackedList
130struct PackedListCore
131{
132 //- Define template name
133 ClassNameNoDebug("PackedList");
134};
135
136} // End namespace Detail
137
138
139/*---------------------------------------------------------------------------*\
140 Class PackedList Declaration
141\*---------------------------------------------------------------------------*/
142
143template<unsigned Width>
144class PackedList
145:
147{
148public:
149
150 // Types and dimension information
151
152 //- The storage block type for bit elements
153 // \note Type name compatibility with boost::dynamic_bitset
154 typedef unsigned int block_type;
155
156 //- The number of bits in a single block
157 // \note Type name compatibility with boost::dynamic_bitset
158 static constexpr unsigned bits_per_block
159 = (std::numeric_limits<block_type>::digits);
160
161 //- The width of an individual element (in bits).
162 static constexpr unsigned element_width = (Width);
164 //- The number of elements stored per data block.
165 static constexpr unsigned elem_per_block = (bits_per_block / Width);
166
167 //- The max value for an element which is also the bit-mask of the
168 //- individual element.
169 // Eg, for Width=2: ((1 << 2) - 1) == 0b0011
170 static constexpr block_type max_value = ((1u << Width) - 1);
171
172 //- Calculate the number of blocks required to _address_ the
173 //- requested number of elements.
174 //
175 // We calculate this:
176 // \code
177 // (numElem / elem_per_block)
178 // + (numElem % elem_per_block) ? 1 : 0
179 // \endcode
180 // But avoiding the modulus operation
181 static constexpr label num_blocks(label numElem) noexcept
183 return ((numElem - 1 + elem_per_block) / elem_per_block);
184 }
185
186 //- Masking for all bits below the element offset.
187 // Ill-defined when elementOffset is out of range.
188 static constexpr block_type mask_lower(unsigned elementOffset)
189 {
190 return (~0u >> (bits_per_block - Width * elementOffset));
191 }
192
193
194protected:
195
196 // Protected Data
197
198 //- The internal container for storing the blocks
200
201 //- The blocks of raw data
203
204 //- Number of entries used
205 label size_;
207 //- Enforce non-zero Width to fit within the block storage and require
208 //- at least 2 items per storage block for general efficiency.
209 //
210 // Thus 1/2 of the base storage size is (sizeof(block_type)*8/2),
211 // or (sizeof(block_type) << 2)
212 static_assert
213 (
214 Width && Width <= (sizeof(block_type) << 2),
215 "Width must be > 0 and minimum of two items per data block"
216 );
217
218
219 // Protected Member Functions
220
221 //- A fill value for complete blocks
222 inline static unsigned int repeated_value(unsigned val);
223
224 //- Read a list entry (allows for specialization)
225 inline static unsigned int readValue(Istream& is);
226
227 //- Read an index/value pair and set accordingly.
228 // For bool specialization, read a single index value
229 inline void setPair(Istream& is);
230
231 //- Write as a dictionary entry
232 void writeEntry(Ostream& os) const;
233
234 //- Clear any partial rubbish in the last addressable block
235 // This \a rubbish may have arisen from block-wise operations etc.
236 inline void clear_trailing_bits();
237
238 //- Copy assignment
239 inline void copyAssign(const PackedList<Width>& rhs);
240
241 //- Find the first block with a '1' bit
242 // \return block number or -1 for an list or if all bits are OFF.
243 inline label first_block() const;
244
245 //- Find the first block with a '0' bit
246 // \return block number or -1 for an list or if all bits are ON.
247 inline label first_not_block() const;
248
249
250public:
251
252 // Forward declaration of access classes
253
254 class reference;
255 typedef unsigned int const_reference;
256
257
258 // Constructors
259
260 //- Default construct, zero-sized and no allocation
261 inline constexpr PackedList() noexcept;
262
263 //- Construct for given number of elements, initializes values to 0
264 inline explicit PackedList(const label numElem);
265
266 //- Construct for given number of elements, and the specified
267 //- value for each element
268 inline PackedList(const label numElem, const unsigned int val);
269
270 //- Construct from Istream
271 inline PackedList(Istream& is);
272
273 //- Copy construct
274 inline PackedList(const PackedList<Width>& list);
275
276 //- Move construct
277 inline PackedList(PackedList<Width>&& list);
278
279 //- Copy construct a subset
280 PackedList(const PackedList<Width>& list, const labelUList& addr);
281
282 //- Copy construct a subset
283 template<class Addr>
285 (
286 const PackedList<Width>& list,
287 const IndirectListBase<label, Addr>& addr
288 );
289
290 //- Copy construct a subset range
291 PackedList(const PackedList<Width>& list, const labelRange& range);
292
293 //- Construct from a list of values
294 inline explicit PackedList(const labelUList& values);
295
296 //- Construct from a indirect list of values
297 template<class Addr>
298 inline explicit PackedList(const IndirectListBase<label, Addr>& values);
299
300 //- Clone
301 inline autoPtr<PackedList<Width>> clone() const;
303
304 // Member Functions
305
306 // Query
307
308 //- Check index is within valid range [0,size)
309 inline void checkIndex(const label i) const;
310
311 //- True if the list is empty (ie, size() is zero).
312 bool empty() const noexcept { return !size_; }
313
314 //- Number of entries.
315 label size() const noexcept { return size_; }
316
317 //- Number of elements that can be stored without reallocating
318 inline label capacity() const noexcept;
319
320 //- True if all entries have identical values (and list is non-empty)
321 bool uniform() const;
322
323 //- Test for equality of sizes and the bits set
324 bool equal(const PackedList<Width>& other) const;
325
326
327 // Access
328
329 //- Get value at index i or 0 for out-of-range.
330 // Never auto-vivify entries.
331 inline unsigned int get(const label i) const;
332
333 //- Set value at index i, default value set is the max_value.
334 // Does auto-vivify for non-existent, non-zero entries.
335 // \return true if value changed.
336 inline bool set(const label i, unsigned int val = ~0u);
337
338 //- Unset the entry at index i.
339 // Never auto-vivify entries.
340 // \return true if the value changed.
341 inline bool unset(const label i);
342
343 //- Return the values as a list of labels
344 labelList values() const;
345
346 //- Return the values as a list of integral type.
347 // The default integral type is unsigned int.
348 template<class IntType = unsigned int>
349 List<IntType> unpack() const;
350
351 //- Return the range of values as a list of integral type.
352 // The default integral type is unsigned int.
353 template<class IntType = unsigned int>
354 List<IntType> unpack(const labelRange& range) const;
355
356 //- Extract the values for the specified locations as
357 //- a list of integral type.
358 // The default integral type is unsigned int.
359 template<class IntType = unsigned int>
360 List<IntType> unpack(const labelUList& locations) const;
361
362
363 // Edit
364
365 //- Assign all entries to the given value.
366 inline void fill(const unsigned int val);
367
368 //- Trim any trailing zero elements, optionally specifying a
369 //- a minimum position, below which trimming will not occur.
370 //
371 // \return true if trimming changed the size.
372 inline bool trim(label minpos = -1);
373
374 //- Clear all bits but do not adjust the addressable size.
375 // \note Method name compatibility with boost::dynamic_bitset
376 inline void reset();
377
378 //- Alter the size of the underlying storage.
379 // The addressed size will be truncated if needed to fit, but will
380 // remain otherwise untouched.
381 inline void setCapacity(const label numElem);
382
383 //- Reset addressable list size, does not shrink the allocated size.
384 // Optionally specify a value for new elements.
385 inline void resize(const label numElem, const unsigned int val = 0u);
386
387 //- Currently identical to resize. Subject to future change (Oct-2021)
388 inline void resize_nocopy(const label numElem);
389
390 //- Reserve allocation space for at least this size
391 //- (uses a size doubling strategy).
392 // Never shrinks the allocated size.
393 inline void reserve(const label numElem);
394
395 //- Reserve allocation space for at least this size
396 //- (uses the specified size without any other resizing strategy).
397 // Never shrinks the allocated size.
398 inline void reserve_exact(const label numElem);
399
400 //- Clear the list, i.e. set addressable size to zero.
401 // Does not adjust the underlying storage
402 inline void clear();
403
404 //- Clear the list and delete storage.
405 inline void clearStorage();
406
407 //- Shrink the allocated space to what is actually used.
408 inline void shrink_to_fit();
409
410 //- Alias for shrink_to_fit()
411 void shrink() { this->shrink_to_fit(); }
412
413 //- Swap contents with argument
414 inline void swap(PackedList<Width>& rhs);
415
416 //- Transfer the contents of the argument list into this list
417 //- and annul the argument list.
418 inline void transfer(PackedList<Width>& rhs);
419
420
421 // Low-level access
422
423 //- The number of internal storage blocks
424 inline label num_blocks() const noexcept;
425
426 //- Return the underlying storage blocks
427 const List<block_type>& storage() const noexcept { return blocks_; }
428
429 //- Return the underlying storage blocks
430 // Manipulate with utmost caution
431 List<block_type>& storage() noexcept { return blocks_; }
432
433 //- A const pointer to the raw storage
434 const block_type* cdata() const noexcept { return blocks_.cdata(); }
435
436 //- A pointer to the raw storage
437 block_type* data() noexcept { return blocks_.data(); }
438
439 //- A const pointer to the raw storage, reinterpreted as byte data
440 inline const char* cdata_bytes() const noexcept;
441
442 //- A pointer to the raw storage, reinterpreted as byte data
443 inline char* data_bytes() noexcept;
444
445 //- The number of integer blocks addressed in the raw storage.
446 //- Same as num_blocks().
447 inline std::streamsize size_data() const noexcept;
448
449 //- The number of bytes addressed in the raw storage
450 //- including any padding.
451 inline std::streamsize size_bytes() const noexcept;
452
453 //- Same as size_bytes()
454 inline std::streamsize byteSize() const noexcept;
455
456
457 // IO
458
459 //- Print bit patterns, optionally with extra debug
460 Ostream& printBits(Ostream& os, bool debugOutput=false) const;
461
462 //- Clear list and read from stream
464
465 //- Write List, with line-breaks in ASCII when length exceeds shortLen.
466 // Using '0' suppresses line-breaks entirely.
467 Ostream& writeList(Ostream& os, label shortLen=0) const;
468
469 //- Write as a dictionary entry with keyword
470 void writeEntry(const word& keyword, Ostream& os) const;
471
472
473 // Member Operators
474
475 //- Append a value at the end of the list
476 inline void push_back(const unsigned int val);
477
478 //- Reduce size by 1 or more elements. Can be called on an empty list.
479 inline void pop_back(label n = 1);
480
481 //- Remove and return the last element
482 inline unsigned int remove();
483
484 //- Identical to get() - get value at index.
485 // Never auto-vivify entries.
486 inline unsigned int operator[](const label i) const;
487
488 //- Non-const access to value at index.
489 // Fatal for out-of-range indices
490 inline reference operator[](const label i);
491
492 //- Copy assignment.
493 inline void operator=(const PackedList<Width>& list);
494
495 //- Move assignment.
496 inline void operator=(PackedList<Width>&& list);
497
498 //- Assign all entries to the given value. fill()
499 inline void operator=(const unsigned int val);
500
501
502 // Access helpers
503
504 //- A reference supporting read/write access to an entry
505 class reference
506 {
507 protected:
508
509 friend class PackedList; // Access for parent
510 void operator&() = delete; // Refuse to provide its address
511
512 //- Reference to the block
513 block_type& ref_;
514
515 //- The bit shift to access the given sub-portion
516 unsigned shift_;
517
518 //- Construct by taking reference of block from within
519 //- the list and the specified index.
520 inline reference(PackedList* parent, const label index);
521
522 //- Get value as unsigned, no range-checking
523 inline unsigned int get() const;
524
525 //- Set value, returning true if changed, no range-checking
526 inline bool set(unsigned int val);
527
528 public:
529
530 //- Copy construct
531 reference(const reference&) noexcept = default;
532
533 //- Move construct
534 reference(reference&&) noexcept = default;
535
536 //- Value assignment
537 inline void operator=(const reference& other);
538
539 //- Value assignment
540 inline void operator=(const unsigned int val);
541
542 //- Conversion operator.
543 inline operator unsigned int () const;
544 };
546
547 // IOstream Operators
548
549 //- Return info proxy,
550 //- used to print information to a stream
552 {
553 return *this;
554 }
555
556 friend Ostream& operator<< <Width>
557 (
558 Ostream& os,
560 );
561
562 friend Istream& operator>> <Width>
563 (
564 Istream& is,
566 );
567
568
569 // Hashing
570
571 //- Hashing functor for PackedList
572 // Seeded with logical size for disambiguation of padding
573 struct hasher
574 {
575 unsigned operator()(const PackedList<Width>& obj) const
577 return Foam::Hasher
578 (
579 obj.cdata(),
580 obj.size_bytes(),
581 unsigned(obj.size())
582 );
583 }
584 };
585
587 // Housekeeping
588
589 //- Deprecated(2020-11) use fill()
590 // \deprecated(2020-11) use fill()
591 void assign(const unsigned int val) { this->fill(val); }
592
593 //- Deprecated(2020-11) use operator=
594 // \deprecated(2020-11) use operator=
595 void assign(const PackedList<Width>& rhs) { (*this) = rhs; }
596
597 //- Alias for resize()
598 void setSize(const label n, unsigned int val = 0u) { resize(n, val); }
599
600 //- Append a value at the end of the list
601 //FOAM_DEPRECATED_FOR(2022-10, "push_back()")
602 PackedList<Width>& append(const unsigned int val)
603 {
604 this->push_back(val);
605 return *this;
606 }
607};
608
609
610// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
611
612//- Hashing for PackedList data
613template<unsigned Width>
614struct Hash<PackedList<Width>> : PackedList<Width>::hasher {};
615
616
617// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
618
619//- Write List to Ostream, as per UList::writeList() with default length.
620// The default short-length is given by Foam::ListPolicy::short_length
621template<unsigned Width>
623{
624 return list.writeList(os, Foam::ListPolicy::short_length<void>::value);
625}
626
627
628//- Test for equality of sizes and the bits set
629template<unsigned Width>
630inline bool operator==(const PackedList<Width>& a, const PackedList<Width>& b);
631
632//- Test for inequality of sizes or the bits set
633template<unsigned Width>
634inline bool operator!=(const PackedList<Width>& a, const PackedList<Width>& b);
635
636
637// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
638
639} // End namespace Foam
640
641// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
642
643#include "PackedListI.H"
644
645// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
646
647#ifdef NoRepository
648 #include "PackedList.C"
649 #include "PackedListIO.C"
650#endif
651
652// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
653
654#endif
655
656// ************************************************************************* //
scalar range
label n
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
A helper class for outputting values to Ostream.
Definition InfoProxy.H:49
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 reference supporting read/write access to an entry.
Definition PackedList.H:694
reference(PackedList *parent, const label index)
Construct by taking reference of block from within the list and the specified index.
unsigned shift_
The bit shift to access the given sub-portion.
Definition PackedList.H:708
reference(reference &&) noexcept=default
Move construct.
reference(const reference &) noexcept=default
Copy construct.
block_type & ref_
Reference to the block.
Definition PackedList.H:703
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
Definition PackedList.H:146
label num_blocks() const noexcept
The number of internal storage blocks.
block_type * data() noexcept
A pointer to the raw storage.
Definition PackedList.H:586
void assign(const PackedList< Width > &rhs)
Deprecated(2020-11) use operator=.
Definition PackedList.H:814
void copyAssign(const PackedList< Width > &rhs)
Copy assignment.
unsigned int const_reference
Definition PackedList.H:302
PackedList< Width > & append(const unsigned int val)
Append a value at the end of the list.
Definition PackedList.H:826
const block_type * cdata() const noexcept
A const pointer to the raw storage.
Definition PackedList.H:581
void shrink()
Alias for shrink_to_fit().
Definition PackedList.H:545
label size_
Number of entries used.
Definition PackedList.H:229
std::streamsize size_data() const noexcept
The number of integer blocks addressed in the raw storage. Same as num_blocks().
static unsigned int readValue(Istream &is)
Read a list entry (allows for specialization).
Definition PackedListI.H:34
void pop_back(label n=1)
Reduce size by 1 or more elements. Can be called on an empty list.
label first_block() const
Find the first block with a '1' bit.
void swap(PackedList< Width > &rhs)
Swap contents with argument.
bool unset(const label i)
Unset the entry at index i.
char * data_bytes() noexcept
A pointer to the raw storage, reinterpreted as byte data.
friend Ostream & operator<<(Ostream &os, const InfoProxy< PackedList< Width > > &info)
void checkIndex(const label i) const
Check index is within valid range [0,size).
List< block_type > block_container
The internal container for storing the blocks.
Definition PackedList.H:219
bool equal(const PackedList< Width > &other) const
Test for equality of sizes and the bits set.
Definition PackedList.C:147
static constexpr block_type mask_lower(unsigned elementOffset)
Masking for all bits below the element offset.
Definition PackedList.H:206
block_container blocks_
The blocks of raw data.
Definition PackedList.H:224
bool empty() const noexcept
True if the list is empty (ie, size() is zero).
Definition PackedList.H:387
void push_back(const unsigned int val)
Append a value at the end of the list.
labelList values() const
Return the values as a list of labels.
Definition PackedList.C:170
void resize_nocopy(const label numElem)
Currently identical to resize. Subject to future change (Oct-2021).
void setSize(const label n, unsigned int val=0u)
Alias for resize().
Definition PackedList.H:819
autoPtr< PackedList< Width > > clone() const
Clone.
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
void fill(const unsigned int val)
Assign all entries to the given value.
void assign(const unsigned int val)
Deprecated(2020-11) use fill().
Definition PackedList.H:807
void shrink_to_fit()
Shrink the allocated space to what is actually used.
List< IntType > unpack() const
Return the values as a list of integral type.
static constexpr block_type max_value
The max value for an element which is also the bit-mask of the individual element.
Definition PackedList.H:182
static unsigned int repeated_value(unsigned val)
Enforce non-zero Width to fit within the block storage and require at least 2 items per storage block...
Definition PackedListI.H:27
void setCapacity(const label numElem)
Alter the size of the underlying storage.
void clear_trailing_bits()
Clear any partial rubbish in the last addressable block.
Definition PackedListI.H:76
static constexpr unsigned element_width
The width of an individual element (in bits).
Definition PackedList.H:169
std::streamsize byteSize() const noexcept
Same as size_bytes().
Ostream & printBits(Ostream &os, bool debugOutput=false) const
Print bit patterns, optionally with extra debug.
void clearStorage()
Clear the list and delete storage.
void operator=(const PackedList< Width > &list)
Copy assignment.
label capacity() const noexcept
Number of elements that can be stored without reallocating.
const List< block_type > & storage() const noexcept
Return the underlying storage blocks.
Definition PackedList.H:569
bool set(const label i, unsigned int val=~0u)
Set value at index i, default value set is the max_value.
Ostream & writeList(Ostream &os, label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
bool trim(label minpos=-1)
Trim any trailing zero elements, optionally specifying a a minimum position, below which trimming wil...
Definition PackedListI.H:90
bool uniform() const
True if all entries have identical values (and list is non-empty).
Definition PackedList.C:85
void reserve(const label numElem)
Reserve allocation space for at least this size (uses a size doubling strategy).
unsigned int get(const label i) const
Get value at index i or 0 for out-of-range.
constexpr PackedList() noexcept
Default construct, zero-sized and no allocation.
static constexpr unsigned elem_per_block
The number of elements stored per data block.
Definition PackedList.H:174
void transfer(PackedList< Width > &rhs)
Transfer the contents of the argument list into this list and annul the argument list.
const char * cdata_bytes() const noexcept
A const pointer to the raw storage, reinterpreted as byte data.
void writeEntry(Ostream &os) const
Write as a dictionary entry.
static constexpr label num_blocks(label numElem) noexcept
Calculate the number of blocks required to _address_ the requested number of elements.
Definition PackedList.H:196
void setPair(Istream &is)
Read an index/value pair and set accordingly.
Definition PackedListI.H:51
label size() const noexcept
Number of entries.
Definition PackedList.H:392
unsigned int block_type
The storage block type for bit elements.
Definition PackedList.H:156
void clear()
Clear the list, i.e. set addressable size to zero.
List< block_type > & storage() noexcept
Return the underlying storage blocks.
Definition PackedList.H:576
Istream & readList(Istream &is)
Clear list and read from stream.
void reset()
Clear all bits but do not adjust the addressable size.
void reserve_exact(const label numElem)
Reserve allocation space for at least this size (uses the specified size without any other resizing s...
label first_not_block() const
Find the first block with a '0' bit.
std::streamsize size_bytes() const noexcept
The number of bytes addressed in the raw storage including any padding.
static constexpr unsigned bits_per_block
The number of bits in a single block.
Definition PackedList.H:164
unsigned int remove()
Remove and return the last element.
InfoProxy< PackedList< Width > > info() const noexcept
Return info proxy, used to print information to a stream.
Definition PackedList.H:761
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
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
Macro definitions for declaring ClassName(), NamespaceName(), etc.
#define ClassNameNoDebug(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition className.H:39
limits reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL))
patchWriters resize(patchIds.size())
OBJstream os(runTime.globalPath()/outputName)
Implementation details for various OpenFOAM classes.
Definition zoneSubSet.C:30
Namespace for OpenFOAM.
bool operator!=(const eddy &a, const eddy &b)
Definition eddy.H:297
List< label > labelList
A List of labels.
Definition List.H:62
bool equal(const T &a, const T &b)
Compare two values for equality.
Definition label.H:180
unsigned Hasher(const void *data, size_t len, unsigned seed=0)
Bob Jenkins's 96-bit mixer hashing function (lookup3).
Definition Hasher.C:575
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
tmp< GeometricField< Type, faPatchField, areaMesh > > operator&(const faMatrix< Type > &, const DimensionedField< Type, areaMesh > &)
Istream & operator>>(Istream &, directionInfo &)
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
const direction noexcept
Definition scalarImpl.H:265
UList< label > labelUList
A UList of labels.
Definition UList.H:75
volScalarField & b
Template-invariant parts for PackedList.
Definition PackedList.H:128
ClassNameNoDebug("PackedList")
Define template name.
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
Hashing functor for PackedList.
Definition PackedList.H:787
unsigned operator()(const PackedList< Width > &obj) const
Definition PackedList.H:788