PackedListI.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 -------------------------------------------------------------------------------
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 \*---------------------------------------------------------------------------*/
28 
29 #include "error.H"
30 
31 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
32 
33 template<unsigned Width>
34 inline unsigned int Foam::PackedList<Width>::repeated_value(unsigned val)
35 {
36  return BitOps::repeat_value<block_type,Width>(val);
37 }
38 
39 
40 template<unsigned Width>
42 {
43  const unsigned int val = readLabel(is);
44 
45  if (val > max_value)
46  {
48  << "Out-of-range value " << val << " for PackedList<" << Width
49  << ">. Maximum permitted value is " << max_value << "."
50  << exit(FatalIOError);
51  }
52 
53  return val;
54 }
55 
56 
57 template<unsigned Width>
59 {
60  is.readBegin("Tuple2<label,uint32>");
61 
62  const label ind = readLabel(is);
63  const unsigned int val = readLabel(is);
64 
65  is.readEnd("Tuple2<label,uint32>");
66 
67  if (val > max_value)
68  {
70  << "Out-of-range value " << val << " for PackedList<" << Width
71  << "> at index " << ind
72  << ". Maximum permitted value is " << max_value << "."
73  << exit(FatalIOError);
74  }
75 
76  set(ind, val);
77 
78  is.check(FUNCTION_NAME);
79 }
80 
81 
82 template<unsigned Width>
84 {
85  // Mask off any partial rubbish in final block
86  const unsigned int blk = size() / elem_per_block;
87  const unsigned int off = size() % elem_per_block;
88 
89  if (off)
90  {
91  blocks_[blk] &= mask_lower(off);
92  }
93 }
94 
95 
96 template<unsigned Width>
97 inline bool Foam::PackedList<Width>::trim(label minpos)
98 {
99  if (empty())
100  {
101  return false; // Trivial case
102  }
103 
104  const label orig = size();
105  if (orig < minpos)
106  {
107  minpos = orig; // Don't allow allow accidental growth!
108  }
109 
110  for (label blocki = num_blocks(size())-1; blocki >= 0; --blocki)
111  {
112  // Truncate to the block begin
113  size_ = blocki * elem_per_block;
114 
115  unsigned int blockval = blocks_[blocki];
116 
117  // Some bits were found in the block, increment size again
118  if (blockval)
119  {
120  for (; blockval; ++size_)
121  {
122  blockval >>= Width;
123  }
124  break;
125  }
126  else if (size_ < minpos)
127  {
128  break;
129  }
130  }
131 
132  if (size_ < minpos)
133  {
134  size_ = minpos;
135  }
136 
137  return (size() != orig);
138 }
139 
140 
141 template<unsigned Width>
143 {
144  // Self-assignment silently ignored
145  blocks_ = rhs.blocks_;
146  size_ = rhs.size_;
147 }
148 
149 
150 // * * * * * * * * * * * * * * * Specializations * * * * * * * * * * * * * * //
151 
152 namespace Foam
153 {
154 
155 // constexpr noexcept
156 template<> inline unsigned int PackedList<1>::repeated_value(unsigned val)
157 {
158  return (val ? ~0u : 0u);
159 }
160 
161 template<> inline unsigned int PackedList<1>::readValue(Istream& is)
162 {
163  return readBool(is);
164 }
165 
166 template<> inline void PackedList<1>::setPair(Istream& is)
167 {
168  set(readLabel(is), true);
169 }
170 
171 } // End namespace Foam
172 
173 
174 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
175 
176 template<unsigned Width>
177 inline constexpr Foam::PackedList<Width>::PackedList() noexcept
178 :
179  blocks_(),
180  size_(0)
181 {}
182 
183 
184 template<unsigned Width>
185 inline Foam::PackedList<Width>::PackedList(const label numElem)
186 :
187  blocks_(num_blocks(numElem), 0u),
188  size_(numElem)
189 {}
190 
191 
192 template<unsigned Width>
194 (
195  const label numElem,
196  const unsigned int val
197 )
198 :
199  blocks_(num_blocks(numElem), 0u),
200  size_(numElem)
201 {
202  if (val)
203  {
204  operator=(val);
205  }
206 }
207 
208 
209 template<unsigned Width>
211 :
212  blocks_(),
213  size_(0)
214 {
215  readList(is);
216 }
217 
218 
219 template<unsigned Width>
221 :
222  blocks_(list.blocks_),
223  size_(list.size_)
224 {}
225 
226 
227 template<unsigned Width>
229 :
230  blocks_(std::move(list.blocks_)),
231  size_(list.size_)
232 {
233  list.size_ = 0;
234 }
235 
236 
237 template<unsigned Width>
239 :
240  blocks_(num_blocks(values.size()), 0u),
241  size_(values.size())
242 {
243  const label len = values.size();
244 
245  // Could add more intelligent filling (blockwise),
246  // but likely done fairly infrequently
247 
248  for (label i = 0; i < len; ++i)
249  {
250  const unsigned int val(values[i]);
251  if (val) set(i, val);
252  }
253 }
254 
255 
256 template<unsigned Width>
257 template<class Addr>
259 (
261 )
262 :
263  blocks_(num_blocks(values.size()), 0u),
264  size_(values.size())
265 {
266  const label len = values.size();
267 
268  // Could add more intelligent filling (blockwise),
269  // but likely done fairly infrequently
270 
271  for (label i = 0; i < len; ++i)
272  {
273  const unsigned int val(values[i]);
274  if (val) set(i, val);
275  }
276 }
277 
278 
279 template<unsigned Width>
282 {
283  return autoPtr<PackedList<Width>>::New(*this);
284 }
285 
286 
287 // * * * * * * * * * * * * * * * * References * * * * * * * * * * * * * * * * //
288 
289 template<unsigned Width>
291 (
292  PackedList<Width>* parent,
293  const label index
294 )
295 :
296  ref_(parent->blocks_[index / elem_per_block]),
297  shift_(Width * (index % elem_per_block))
298 {}
299 
300 
301 template<unsigned Width>
302 inline unsigned int Foam::PackedList<Width>::reference::get() const
303 {
304  return ((ref_ >> shift_) & max_value);
305 }
306 
307 
308 template<unsigned Width>
309 inline bool Foam::PackedList<Width>::reference::set(const unsigned int val)
310 {
311  const unsigned int mask = (max_value << shift_);
312  const unsigned int prev = ref_;
313 
314  if (val >= max_value)
315  {
316  ref_ |= mask; // Overflow is max_value, so fill entirely
317  }
318  else
319  {
320  ref_ &= ~mask;
321  ref_ |= mask & (val << shift_);
322  }
323 
324  return (prev != ref_);
325 }
326 
327 
328 template<unsigned Width>
330 (
331  const reference& other
332 )
333 {
334  // Accepts self-assignment
335  this->set(other.get());
336 }
337 
338 
339 template<unsigned Width>
341 (
342  const unsigned int val
343 )
344 {
345  this->set(val);
346 }
347 
348 
349 template<unsigned Width>
351 {
352  return this->get();
353 }
354 
355 
356 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
357 
358 template<unsigned Width>
359 inline void Foam::PackedList<Width>::checkIndex(const label i) const
360 {
361  if (!size_)
362  {
364  << "attempt to access element " << i << " from zero sized list"
365  << abort(FatalError);
366  }
367  else if (i < 0 || i >= size_)
368  {
370  << "index " << i << " out of range [0," << size_ << ")"
371  << abort(FatalError);
372  }
373 }
374 
375 
376 template<unsigned Width>
377 inline Foam::label Foam::PackedList<Width>::size() const noexcept
378 {
379  return size_;
380 }
381 
382 
383 template<unsigned Width>
384 inline bool Foam::PackedList<Width>::empty() const noexcept
385 {
386  return !size_;
387 }
388 
389 
390 template<unsigned Width>
391 inline Foam::label Foam::PackedList<Width>::capacity() const noexcept
392 {
393  return elem_per_block * blocks_.size();
394 }
395 
396 
397 template<unsigned Width>
399 (
400  const label numElem
401 )
402 {
403  this->resize(numElem);
404 }
405 
406 
407 template<unsigned Width>
409 (
410  const label newSize,
411  const unsigned int val
412 )
413 {
414  reserve(newSize);
415 
416  const label oldSize = size();
417  size_ = newSize;
418 
419  if (oldSize < newSize)
420  {
421  // Fill new elements or newly exposed elements
422  if (val)
423  {
424  // Fill value for complete blocks
425  const unsigned int blockval = repeated_value(val);
426 
427  // Fill complete blocks
428  const label oldLen = num_blocks(oldSize);
429  const label newLen = num_blocks(size());
430  for (label blocki = oldLen; blocki < newLen; ++blocki)
431  {
432  blocks_[blocki] = blockval;
433  }
434 
435  // Finish previous partial block, preserve existing value
436  {
437  const unsigned int blk = oldSize / elem_per_block;
438  const unsigned int off = oldSize % elem_per_block;
439  if (off)
440  {
441  const unsigned int mask = mask_lower(off);
442 
443  blocks_[blk] &= mask;
444  blocks_[blk] |= ~mask & blockval;
445  }
446  }
447 
449  }
450  }
451  else if (newSize < oldSize)
452  {
453  // The list is now shorter than before, so we zero assign the unused
454  // blocks and any trailing junk. This costs slightly here, but make
455  // things much simpler elsewhere.
456 
457  // Clear complete blocks
458  const label oldLen = num_blocks(oldSize);
459  const label newLen = num_blocks(size());
460  for (label blocki = newLen; blocki < oldLen; ++blocki)
461  {
462  blocks_[blocki] = 0u;
463  }
464 
466  }
467 }
468 
469 
470 template<unsigned Width>
471 inline void Foam::PackedList<Width>::setCapacity(const label numElem)
472 {
473  const label nblocks = num_blocks(numElem);
474 
475  blocks_.resize(nblocks, 0u);
476 
477  if (numElem < size())
478  {
479  size_ = numElem;
481  }
482 }
483 
484 
485 template<unsigned Width>
486 inline void Foam::PackedList<Width>::reserve(const label numElem)
487 {
488  const label oldLen = blocks_.size();
489  const label newLen = num_blocks(numElem);
490 
491  // Allocate more capacity if necessary
492  if (oldLen < newLen)
493  {
495  (
496  // SizeMin=16, allocation doubling
497  max(16, max(newLen, 2*oldLen)),
498  0u
499  );
500  }
501 }
502 
503 
504 template<unsigned Width>
506 {
507  blocks_ = 0u;
508 }
509 
510 
511 template<unsigned Width>
513 {
514  reset();
515  size_ = 0;
516 }
517 
518 
519 template<unsigned Width>
521 {
522  blocks_.clear();
523  size_ = 0;
524 }
525 
526 
527 template<unsigned Width>
529 {
530  // Any unneeded space allocated?
531  const label nblocks = num_blocks(size());
532  if (nblocks < blocks_.size())
533  {
534  blocks_.resize(nblocks);
535  }
536 }
537 
538 
539 template<unsigned Width>
541 {
542  return blocks_;
543 }
544 
545 
546 template<unsigned Width>
548 {
549  return blocks_;
550 }
551 
552 
553 template<unsigned Width>
554 inline Foam::label Foam::PackedList<Width>::nBlocks() const
555 {
556  return num_blocks(size());
557 }
558 
559 
560 template<unsigned Width>
561 inline const unsigned int* Foam::PackedList<Width>::cdata() const noexcept
562 {
563  return blocks_.cdata();
564 }
565 
566 
567 template<unsigned Width>
568 inline unsigned int* Foam::PackedList<Width>::data() noexcept
569 {
570  return blocks_.data();
571 }
572 
573 
574 template<unsigned Width>
575 inline const char* Foam::PackedList<Width>::cdata_bytes() const noexcept
576 {
577  return blocks_.cdata_bytes();
578 }
579 
580 
581 template<unsigned Width>
582 inline char* Foam::PackedList<Width>::data_bytes() noexcept
583 {
584  return blocks_.data_bytes();
585 }
586 
587 
588 template<unsigned Width>
589 inline std::streamsize Foam::PackedList<Width>::size_bytes() const noexcept
590 {
591  return num_blocks(size()) * sizeof(block_type);
592 }
593 
594 
595 template<unsigned Width>
596 inline std::streamsize Foam::PackedList<Width>::byteSize() const noexcept
597 {
598  return this->size_bytes();
599 }
600 
601 
602 template<unsigned Width>
604 {
605  if (this == &rhs)
606  {
607  return; // Self-swap is a no-op
608  }
609 
610  blocks_.swap(rhs.blocks_);
611  std::swap(size_, rhs.size_);
612 }
613 
614 
615 template<unsigned Width>
617 {
618  if (this == &rhs)
619  {
620  return; // Self-assignment is a no-op
621  }
622 
623  blocks_.transfer(rhs.blocks_);
624  size_ = rhs.size_;
625  rhs.size_ = 0;
626 }
627 
628 
629 template<unsigned Width>
630 inline unsigned int Foam::PackedList<Width>::get(const label i) const
631 {
632  if (i < 0 || i >= size())
633  {
634  #ifdef FULLDEBUG
635  if (i < 0)
636  {
638  << "Ignoring attempt to get a negative index " << i
639  << " range is [0," << size_ << ")"
640  << endl;
641  }
642  #endif
643 
644  return 0u; // Out-of-bounds (lazy): return 0 (false)
645  }
646 
647  return reference(const_cast<PackedList<Width>*>(this), i).get();
648 }
649 
650 
651 template<unsigned Width>
653 (
654  const label i,
655  const unsigned int val
656 )
657 {
658  if (i < 0)
659  {
660  #ifdef FULLDEBUG
662  << "Ignoring attempt to set a negative index " << i
663  << " range is [0," << size_ << ")"
664  << endl;
665  #endif
666 
667  return false; // Out-of-bounds: ignore
668  }
669  else if (i >= size())
670  {
671  if (!val) // Unset out-of-bounds: ignore
672  {
673  return false;
674  }
675 
676  resize(i + 1); // Lazy evaluation: adjust size for assign
677  }
678 
679  return reference(this, i).set(val);
680 }
681 
682 
683 template<unsigned Width>
684 inline bool Foam::PackedList<Width>::unset(const label i)
685 {
686  if (i < 0 || i >= size())
687  {
688  return false; // Unset out-of-bounds: ignore
689  }
690 
691  return reference(this, i).set(0u);
692 }
693 
694 
695 template<unsigned Width>
697 Foam::PackedList<Width>::append(const unsigned int val)
698 {
699  const label idx = size();
700  reserve(idx + 1);
701  ++size_;
702 
703  reference(this, idx).set(val);
704  return *this;
705 }
706 
707 
708 template<unsigned Width>
709 inline unsigned int Foam::PackedList<Width>::remove()
710 {
711  // Location of last element and simultaneously the new size
712  const label idx = size()-1;
713 
714  if (idx < 0)
715  {
717  << "List is empty" << abort(FatalError);
718  }
719 
720  const unsigned int old = reference(this, idx).get();
721  resize(idx);
722 
723  return old;
724 }
725 
726 
727 template<unsigned Width>
728 inline void Foam::PackedList<Width>::fill(const unsigned int val)
729 {
730  if (empty())
731  {
732  return; // Trivial case
733  }
734 
735  const label nblocks = num_blocks(size());
736 
737  // Fill value for complete blocks
738  const unsigned int blockval = (val ? repeated_value(val) : 0u);
739 
740  for (label blocki=0; blocki < nblocks; ++blocki)
741  {
742  blocks_[blocki] = blockval;
743  }
744 
745  if (val)
746  {
748  }
749 }
750 
751 
752 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
753 
754 template<unsigned Width>
755 inline unsigned int Foam::PackedList<Width>::operator[](const label i) const
756 {
757  return get(i);
758 }
759 
760 
761 template<unsigned Width>
764 {
765  #ifdef FULLDEBUG
766  checkIndex(i);
767  #endif
768  return reference(this, i);
769 }
770 
771 
772 template<unsigned Width>
774 {
775  copyAssign(rhs);
776 }
777 
778 
779 template<unsigned Width>
781 {
782  transfer(rhs);
783 }
784 
785 
786 template<unsigned Width>
787 inline void Foam::PackedList<Width>::operator=(const unsigned int val)
788 {
789  fill(val);
790 }
791 
792 
793 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
794 
795 template<unsigned Width>
796 inline bool Foam::operator==
797 (
798  const PackedList<Width>& a,
799  const PackedList<Width>& b
800 )
801 {
802  return a.equal(b);
803 }
804 
805 
806 template<unsigned Width>
807 inline bool Foam::operator!=
808 (
809  const PackedList<Width>& a,
810  const PackedList<Width>& b
811 )
812 {
813  return !a.equal(b);
814 }
815 
816 
817 // ************************************************************************* //
Foam::PackedList::reset
void reset()
Clear all bits but do not adjust the addressable size.
Definition: PackedListI.H:505
Foam::PackedList::resize
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
Definition: PackedListI.H:409
Foam::PackedList::reference::set
bool set(unsigned int val)
Set value, returning true if changed, no range-checking.
Definition: PackedListI.H:309
Foam::BitOps::set
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Definition: BitOps.C:37
Foam::PackedList::reference::ref_
block_type & ref_
Reference to the block.
Definition: PackedList.H:474
Foam::PackedList::reserve
void reserve(const label numElem)
Reserve allocation space for at least this size.
Definition: PackedListI.H:486
Foam::List::resize
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
Foam::PackedList::reference
A reference supporting read/write access to an entry.
Definition: PackedList.H:466
Foam::HashTableOps::values
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Definition: HashOps.H:149
Foam::PackedList::clone
autoPtr< PackedList< Width > > clone() const
Clone.
Definition: PackedListI.H:281
Foam::PackedList::block_type
unsigned int block_type
The storage block type for bit elements.
Definition: PackedList.H:136
Foam::PackedList::reference::reference
reference(PackedList *parent, const label index)
Foam::PackedList::size_bytes
std::streamsize size_bytes() const noexcept
Definition: PackedListI.H:589
Foam::PackedList::nBlocks
label nBlocks() const
The number of internal storage blocks.
Definition: PackedListI.H:554
Foam::PackedList::clear_trailing_bits
void clear_trailing_bits()
Clear any partial rubbish in the last addressable block.
Definition: PackedListI.H:83
Foam::FatalIOError
IOerror FatalIOError
Foam::PackedList::empty
bool empty() const noexcept
True if the list is empty (ie, size() is zero).
Definition: PackedListI.H:384
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::PackedList::PackedList
constexpr PackedList() noexcept
Default construct, zero-sized and no allocation.
Definition: PackedListI.H:177
Foam::Istream::readEnd
bool readEnd(const char *funcName)
End read of data chunk, ends with ')'.
Definition: Istream.C:129
Foam::PackedList::checkIndex
void checkIndex(const label i) const
Check index is within valid range [0,size)
Definition: PackedListI.H:359
Foam::PackedList::swap
void swap(PackedList< Width > &rhs)
Swap contents with argument.
Definition: PackedListI.H:603
Foam::PackedList::get
unsigned int get(const label i) const
Get value at index i or 0 for out-of-range.
Definition: PackedListI.H:630
Foam::PackedList::reference::get
unsigned int get() const
Get value as unsigned, no range-checking.
Definition: PackedListI.H:302
Foam::Istream::readBegin
bool readBegin(const char *funcName)
Begin read of data chunk, starts with '('.
Definition: Istream.C:111
Foam::PackedList::cdata_bytes
const char * cdata_bytes() const noexcept
A const pointer to the raw storage, reinterpreted as byte data.
Definition: PackedListI.H:575
Foam::PackedList::mask_lower
static constexpr block_type mask_lower(unsigned elementOffset)
Masking for all bits below the element offset.
Definition: PackedList.H:170
Foam::PackedList::size_
label size_
Number of entries used.
Definition: PackedList.H:187
Foam::PackedList::data
unsigned int * data() noexcept
A pointer to the raw storage.
Definition: PackedListI.H:568
Foam::PackedList::blocks_
block_container blocks_
The blocks of raw data.
Definition: PackedList.H:184
Foam::PackedList::repeated_value
static unsigned int repeated_value(unsigned val)
A fill value for complete blocks.
Definition: PackedListI.H:34
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
error.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::readBool
bool readBool(Istream &is)
Read bool from stream using Foam::Switch(Istream&)
Definition: bool.C:75
Foam::List::transfer
void transfer(List< T > &list)
Definition: List.C:456
Foam::PackedList::unset
bool unset(const label i)
Unset the entry at index i.
Definition: PackedListI.H:684
Foam::PackedList::remove
unsigned int remove()
Remove and return the last element.
Definition: PackedListI.H:709
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::PackedList::fill
void fill(const unsigned int val)
Assign all entries to the given value.
Definition: PackedListI.H:728
Foam::PackedList::cdata
const unsigned int * cdata() const noexcept
A const pointer to the raw storage.
Definition: PackedListI.H:561
Foam::PackedList::operator[]
unsigned int operator[](const label i) const
Identical to get() - get value at index.
Definition: PackedListI.H:755
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
Foam::FatalError
error FatalError
Foam::PackedList::transfer
void transfer(PackedList< Width > &rhs)
Definition: PackedListI.H:616
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::PackedList::append
PackedList< Width > & append(const unsigned int val)
Append a value at the end of the list.
Definition: PackedListI.H:697
Foam::PackedList::equal
bool equal(const PackedList< Width > &other) const
Test for equality of sizes and the bits set.
Definition: PackedList.C:152
Foam::PackedList::setPair
void setPair(Istream &is)
Read an index/value pair and set accordingly.
Definition: PackedListI.H:58
Foam::PackedList::max_value
static constexpr block_type max_value
Definition: PackedList.H:152
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::PackedList::elem_per_block
static constexpr unsigned elem_per_block
The number of elements stored per data block.
Definition: PackedList.H:147
Foam::readLabel
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Definition: label.H:66
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::PackedList
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
Definition: PackedList.H:108
Foam::PackedList::operator=
void operator=(const PackedList< Width > &lst)
Copy assignment.
Definition: PackedListI.H:773
Foam::PackedList::size
label size() const noexcept
Number of entries.
Definition: PackedListI.H:377
Foam::UList< label >
Foam::List::clear
void clear()
Clear the list, i.e. set size to zero.
Definition: ListI.H:116
Foam::PackedList::trim
bool trim(label minpos=-1)
Definition: PackedListI.H:97
Foam::PackedList::storage
const List< unsigned int > & storage() const
Return the underlying storage blocks.
Definition: PackedListI.H:547
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:295
Foam::PackedList::data_bytes
char * data_bytes() noexcept
A pointer to the raw storage, reinterpreted as byte data.
Definition: PackedListI.H:582
Foam::PackedList::clearStorage
void clearStorage()
Clear the list and delete storage.
Definition: PackedListI.H:520
Foam::PackedList::set
bool set(const label i, unsigned int val=~0u)
Set value at index i, default value set is the max_value.
Definition: PackedListI.H:653
Foam::PackedList::shrink
void shrink()
Shrink the allocated space to what is actually used.
Definition: PackedListI.H:528
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Foam::IndirectListBase
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
Definition: IndirectListBase.H:56
Foam::PackedList::byteSize
std::streamsize byteSize() const noexcept
Definition: PackedListI.H:596
Foam::PackedList::resize_nocopy
void resize_nocopy(const label numElem)
Currently identical to resize. Subject to future change (Oct-2021)
Definition: PackedListI.H:399
Foam::PackedList::reference::shift_
unsigned shift_
The bit shift to access the given sub-portion.
Definition: PackedList.H:477
Foam::PackedList::capacity
label capacity() const noexcept
The number of elements that can be stored with reallocating.
Definition: PackedListI.H:391
Foam::PackedList::copyAssign
void copyAssign(const PackedList< Width > &rhs)
Copy assignment.
Definition: PackedListI.H:142
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:328
Foam::PackedList::num_blocks
static constexpr label num_blocks(label numElem) noexcept
Definition: PackedList.H:163
Foam::PackedList::clear
void clear()
Clear the list, i.e. set addressable size to zero.
Definition: PackedListI.H:512
Foam::PackedList::readValue
static unsigned int readValue(Istream &is)
Read a list entry (allows for specialization)
Definition: PackedListI.H:41
Foam::PackedList::setCapacity
void setCapacity(const label numElem)
Alter the size of the underlying storage.
Definition: PackedListI.H:471