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