PackedListI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include <climits>
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 template<unsigned nBits>
31 inline unsigned int Foam::PackedList<nBits>::max_bits()
32 {
33  return sizeof(StorageType)*CHAR_BIT - 1;
34 }
35 
36 
37 template<unsigned nBits>
39 {
40  return (1u << nBits) - 1;
41 }
42 
43 
44 template<unsigned nBits>
45 inline unsigned int Foam::PackedList<nBits>::packing()
46 {
47  return sizeof(StorageType)*CHAR_BIT / nBits;
48 }
49 
50 
51 template<unsigned nBits>
52 inline unsigned int Foam::PackedList<nBits>::maskLower(unsigned offset)
53 {
54  // Return (1u << (nBits * offset)) - 1;
55  // The next one works more reliably with overflows
56  // eg, when compiled without optimisation
57  return (~0u >> ( sizeof(StorageType)*CHAR_BIT - nBits * offset));
58 }
59 
60 
61 template<unsigned nBits>
63 {
64  return (nElem + packing() - 1) / packing();
65 }
66 
67 
68 namespace Foam
69 {
70  // Template specialisation for bool entries
71  template<>
72  inline unsigned int Foam::PackedList<1>::readValue(Istream& is)
73  {
74  return readBool(is);
75  }
76 
77  // Template specialisation for bool entries
78  template<>
80  {
81  set(readLabel(is), true);
82  }
83 
84  // Template specialisation for bool entries
85  template<>
87  {
88  if (this->get())
89  {
90  os << index_;
91 
92  return true;
93  }
94  else
95  {
96  return false;
97  }
98  }
99 }
100 
101 
102 template<unsigned nBits>
104 {
105  const unsigned int val = readLabel(is);
106 
107  if (val > max_value())
108  {
110  << "Out-of-range value " << val << " for PackedList<" << nBits
111  << ">. Maximum permitted value is " << max_value() << "."
112  << exit(FatalIOError);
113  }
114 
115  return val;
116 }
117 
118 
119 template<unsigned nBits>
121 {
122  is.readBegin("Tuple2<label, unsigned int>");
123 
124  const label ind = readLabel(is);
125  const unsigned int val = readLabel(is);
126 
127  is.readEnd("Tuple2<label, unsigned int>");
128 
129  if (val > max_value())
130  {
132  << "Out-of-range value " << val << " for PackedList<" << nBits
133  << "> at index " << ind
134  << ". Maximum permitted value is " << max_value() << "."
135  << exit(FatalIOError);
136  }
137 
138  set(ind, val);
139 
140  // Check state of Istream
141  is.check("PackedList<nBits>::setPair(Istream&)");
142 }
143 
144 
145 template<unsigned nBits>
147 {
148  const label val = this->get();
149 
150  if (val)
151  {
152  os << token::BEGIN_LIST
153  << index_ << token::SPACE << val
154  << token::END_LIST;
155 
156  return true;
157  }
158  else
159  {
160  return false;
161  }
162 }
163 
164 
165 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
166 
167 template<unsigned nBits>
169 :
170  PackedListCore(),
171  StorageList(),
172  size_(0)
173 {}
174 
175 
176 template<unsigned nBits>
178 :
179  PackedListCore(),
181  size_(size)
182 {}
183 
184 
185 template<unsigned nBits>
187 (
188  const label size,
189  const unsigned int val
190 )
191 :
192  PackedListCore(),
193  StorageList(packedLength(size), 0u),
194  size_(size)
195 {
196  if (val)
197  {
198  operator=(val);
199  }
200 }
201 
202 
203 template<unsigned nBits>
205 :
206  PackedListCore(),
208  size_(0)
209 {
210  read(is);
211 }
212 
213 
214 template<unsigned nBits>
216 :
217  PackedListCore(),
218  StorageList(lst),
219  size_(lst.size_)
220 {}
221 
222 
223 template<unsigned nBits>
225 {
226  transfer(lst);
227 }
228 
229 
230 template<unsigned nBits>
232 :
233  PackedListCore(),
234  StorageList(packedLength(lst.size()), 0u),
235  size_(lst.size())
236 {
237  forAll(lst, i)
238  {
239  set(i, lst[i]);
240  }
241 }
242 
243 
244 template<unsigned nBits>
246 :
247  PackedListCore(),
248  StorageList(packedLength(lst.size()), 0u),
249  size_(lst.size())
250 {
251  forAll(lst, i)
252  {
253  set(i, lst[i]);
254  }
255 }
256 
257 
258 template<unsigned nBits>
261 {
263 }
264 
265 
266 // * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
267 
268 template<unsigned nBits>
270 :
271  list_(0),
272  index_(0)
273 {}
274 
275 
276 template<unsigned nBits>
278 (
279  const PackedList<nBits>* lst,
280  const label i
281 )
282 :
283  list_(const_cast<PackedList<nBits>*>(lst)),
284  index_(i)
285 {}
286 
287 
288 template<unsigned nBits>
289 inline unsigned int
291 {
292  const unsigned int seg = index_ / packing();
293  const unsigned int off = index_ % packing();
294 
295  const unsigned int& stored = list_->StorageList::operator[](seg);
296  return (stored >> (nBits * off)) & max_value();
297 }
298 
299 
300 template<unsigned nBits>
301 inline bool
302 Foam::PackedList<nBits>::iteratorBase::set(const unsigned int val) const
303 {
304  const unsigned int seg = index_ / packing();
305  const unsigned int off = index_ % packing();
306 
307  const unsigned int startBit = nBits * off;
308  const unsigned int mask = max_value() << startBit;
309 
310  unsigned int& stored = list_->StorageList::operator[](seg);
311  const unsigned int prev = stored;
312 
313  if (val >= max_value())
314  {
315  // Overflow is max_value, fill everything
316  stored |= mask;
317  }
318  else
319  {
320  stored &= ~mask;
321  stored |= mask & (val << startBit);
322  }
323 
324  return prev != stored;
325 }
326 
327 
328 template<unsigned nBits>
330 {
331  return index_;
332 }
333 
334 
335 template<unsigned nBits>
337 (
338  const iteratorBase& iter
339 ) const
340 {
341  return this->get() == iter.get();
342 }
343 
344 
345 template<unsigned nBits>
347 (
348  const iteratorBase& iter
349 ) const
350 {
351  return this->get() != iter.get();
352 }
353 
354 
355 template<unsigned nBits>
357 (
358  const iteratorBase& iter
359 ) const
360 {
361  const unsigned int val = iter.get();
362  this->set(val);
363 }
364 
365 
366 template<unsigned nBits>
368 (
369  const unsigned int val
370 ) const
371 {
372  // Lazy evaluation - increase size on assignment
373  if (index_ >= list_->size_)
374  {
375  list_->resize(index_ + 1);
376  }
377 
378  this->set(val);
379 }
380 
381 
382 template<unsigned nBits>
384 unsigned int () const
385 {
386  // Lazy evaluation - return 0 for out-of-range
387  if (index_ >= list_->size_)
388  {
389  return 0;
390  }
391 
392  return this->get();
393 }
394 
395 
396 template<unsigned nBits>
398 :
399  iteratorBase()
400 {}
401 
402 
403 template<unsigned nBits>
405 :
406  iteratorBase()
407 {}
408 
409 
410 template<unsigned nBits>
412 (
413  const iteratorBase& iter
414 )
415 :
416  iteratorBase(iter)
417 {
418  // Avoid going past end()
419  // eg, iter = iterator(list, Inf)
420  if (this->index_ > this->list_->size_)
421  {
422  this->index_ = this->list_->size_;
423  }
424 }
425 
426 
427 template<unsigned nBits>
429 (
430  const iteratorBase& iter
431 )
432 :
433  iteratorBase(iter)
434 {
435  // Avoid going past end()
436  // eg, iter = iterator(list, Inf)
437  if (this->index_ > this->list_->size_)
438  {
439  this->index_ = this->list_->size_;
440  }
441 }
442 
443 
444 template<unsigned nBits>
446 (
447  const PackedList<nBits>* lst,
448  const label i
449 )
450 :
451  iteratorBase(lst, i)
452 {}
453 
454 
455 template<unsigned nBits>
457 (
458  const PackedList<nBits>* lst,
459  const label i
460 )
461 :
462  iteratorBase(lst, i)
463 {}
464 
465 
466 template<unsigned nBits>
468 (
469  const iterator& iter
470 )
471 :
472  iteratorBase(static_cast<const iteratorBase&>(iter))
473 {}
474 
475 
476 template<unsigned nBits>
478 (
479  const iteratorBase& iter
480 ) const
481 {
482  return this->index_ == iter.index_;
483 }
484 
485 
486 template<unsigned nBits>
488 (
489  const iteratorBase& iter
490 ) const
491 {
492  return this->index_ != iter.index_;
493 }
494 
495 
496 template<unsigned nBits>
498 (
499  const iteratorBase& iter
500 ) const
501 {
502  return this->index_ == iter.index_;
503 }
504 
505 
506 template<unsigned nBits>
508 (
509  const iteratorBase& iter
510 ) const
511 {
512  return this->index_ != iter.index_;
513 }
514 
515 
516 template<unsigned nBits>
518 (
519  const iteratorBase& iter
520 )
521 {
522  this->list_ = iter.list_;
523  this->index_ = iter.index_;
524 
525  // Avoid going past end()
526  // eg, iter = iterator(list, Inf)
527  if (this->index_ > this->list_->size_)
528  {
529  this->index_ = this->list_->size_;
530  }
531 }
532 
533 
534 template<unsigned nBits>
536 (
537  const iteratorBase& iter
538 )
539 {
540  this->list_ = iter.list_;
541  this->index_ = iter.index_;
542 
543  // Avoid going past end()
544  // eg, iter = iterator(list, Inf)
545  if (this->index_ > this->list_->size_)
546  {
547  this->index_ = this->list_->size_;
548  }
549 }
550 
551 
552 template<unsigned nBits>
553 inline typename Foam::PackedList<nBits>::iterator&
555 {
556  ++this->index_;
557  return *this;
558 }
559 
560 
561 template<unsigned nBits>
564 {
565  ++this->index_;
566  return *this;
567 }
568 
569 
570 template<unsigned nBits>
571 inline typename Foam::PackedList<nBits>::iterator
573 {
574  iterator old = *this;
575  ++this->index_;
576  return old;
577 }
578 
579 
580 template<unsigned nBits>
583 {
584  const_iterator old = *this;
585  ++this->index_;
586  return old;
587 }
588 
589 
590 template<unsigned nBits>
591 inline typename Foam::PackedList<nBits>::iterator&
593 {
594  --this->index_;
595  return *this;
596 }
597 
598 
599 template<unsigned nBits>
602 {
603  --this->index_;
604  return *this;
605 }
606 
607 
608 template<unsigned nBits>
609 inline typename Foam::PackedList<nBits>::iterator
611 {
612  iterator old = *this;
613  --this->index_;
614  return old;
615 }
616 
617 
618 template<unsigned nBits>
621 {
622  const_iterator old = *this;
623  --this->index_;
624  return old;
625 }
626 
627 
628 template<unsigned nBits>
629 inline const typename Foam::PackedList<nBits>::iteratorBase&
631 {
632  return static_cast<const iteratorBase&>(*this);
633 }
634 
635 
636 template<unsigned nBits>
637 inline const typename Foam::PackedList<nBits>::iteratorBase&
639 {
640  return static_cast<const iteratorBase&>(*this);
641 }
642 
643 
644 template<unsigned nBits>
645 inline typename Foam::PackedList<nBits>::iterator
647 {
648  return iterator(this, 0);
649 }
650 
651 
652 template<unsigned nBits>
655 {
656  return const_iterator(this, 0);
657 }
658 
659 
660 template<unsigned nBits>
663 {
664  return const_iterator(this, 0);
665 }
666 
667 
668 template<unsigned nBits>
669 inline typename Foam::PackedList<nBits>::iterator
671 {
672  return iterator(this, size_);
673 }
674 
675 
676 template<unsigned nBits>
679 {
680  return const_iterator(this, size_);
681 }
682 
683 
684 template<unsigned nBits>
687 {
688  return const_iterator(this, size_);
689 }
690 
691 
692 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
693 
694 template<unsigned nBits>
696 {
697  return size_;
698 }
699 
700 
701 template<unsigned nBits>
703 {
704  return !size_;
705 }
706 
707 
708 template<unsigned nBits>
710 (
711  const label newSize,
712  const unsigned int& val
713 )
714 {
715  reserve(newSize);
716 
717  const label oldSize = size_;
718  size_ = newSize;
719 
720  if (size_ > oldSize)
721  {
722  // Fill new elements or newly exposed elements
723  if (val)
724  {
725  // Fill value for complete segments
726  unsigned int fill = val;
727 
728  if (val >= max_value())
729  {
730  // Fill everything
731  fill = maskLower(packing());
732  }
733  else
734  {
735  for (unsigned int i = 1; i < packing(); ++i)
736  {
737  fill |= (fill << nBits);
738  }
739  }
740 
741  // Fill in complete segments
742  const label oldLen = packedLength(oldSize);
743  const label newLen = packedLength(size_);
744  for (label i=oldLen; i < newLen; ++i)
745  {
746  StorageList::operator[](i) = fill;
747  }
748 
749  // Finish previous partial segment, preserve existing value
750  {
751  const unsigned int off = oldSize % packing();
752  if (off)
753  {
754  const unsigned int seg = oldSize / packing();
755  const unsigned int mask = maskLower(off);
756 
757  StorageList::operator[](seg) &= mask;
758  StorageList::operator[](seg) |= ~mask & fill;
759  }
760  }
761 
762 
763  // Mask off the (new) final partial segment
764  {
765  const unsigned int off = size_ % packing();
766  if (off)
767  {
768  const unsigned int seg = size_ / packing();
769 
770  StorageList::operator[](seg) &= maskLower(off);
771  }
772  }
773  }
774  }
775  else if (size_ < oldSize)
776  {
777  // Resize shrinking
778  // - clear newly exposed elements
779 
780  // Fill in complete segments
781  const label oldLen = packedLength(oldSize);
782  const label newLen = packedLength(size_);
783  for (label i=newLen; i < oldLen; ++i)
784  {
785  StorageList::operator[](i) = 0u;
786  }
787 
788  // Mask off the final partial segment
789  {
790  const unsigned int off = size_ % packing();
791  if (off)
792  {
793  const unsigned int seg = size_ / packing();
794 
795  StorageList::operator[](seg) &= maskLower(off);
796  }
797  }
798  }
799 }
800 
801 
802 template<unsigned nBits>
804 (
805  const label newSize,
806  const unsigned int& val
807 )
808 {
809  resize(newSize, val);
810 }
811 
812 
813 
814 template<unsigned nBits>
816 {
817  return packing() * StorageList::size();
818 }
819 
820 
821 template<unsigned nBits>
823 {
824  StorageList::setSize(packedLength(nElem), 0u);
825 
826  // Truncate addressed size too
827  if (size_ > nElem)
828  {
829  size_ = nElem;
830 
831  // Mask off the final partial segment
832  const unsigned int off = size_ % packing();
833  if (off)
834  {
835  const unsigned int seg = size_ / packing();
836 
837  StorageList::operator[](seg) &= maskLower(off);
838  }
839  }
840 }
841 
842 
843 template<unsigned nBits>
844 inline void Foam::PackedList<nBits>::reserve(const label nElem)
845 {
846  const label len = packedLength(nElem);
847 
848  // Need more capacity?
849  if (len > StorageList::size())
850  {
851  // Like DynamicList with SizeInc=0, SizeMult=2, SizeDiv=1
853  (
854  max
855  (
856  len,
857  StorageList::size()*2
858  ),
859  0u
860  );
861  }
862 }
863 
864 
865 template<unsigned nBits>
867 {
868  StorageList::operator=(0u);
869 }
870 
871 
872 template<unsigned nBits>
874 {
875  reset();
876  size_ = 0;
877 }
878 
879 
880 template<unsigned nBits>
882 {
884  size_ = 0;
885 }
886 
887 
888 template<unsigned nBits>
890 {
891  // Any uneed space allocated?
892  const label len = packedLength();
893  if (len < StorageList::size())
894  {
896  }
897 }
898 
899 template<unsigned nBits>
901 {
902  return static_cast<StorageList&>(*this);
903 }
904 
905 
906 template<unsigned nBits>
908 {
909  return static_cast<const StorageList&>(*this);
910 }
911 
912 
913 template<unsigned nBits>
915 {
916  return packedLength(size_);
917 }
918 
919 
920 template<unsigned nBits>
921 inline std::streamsize Foam::PackedList<nBits>::byteSize() const
922 {
923  return packedLength() * sizeof(StorageType);
924 }
925 
926 
927 template<unsigned nBits>
929 {
930  size_ = lst.size_;
931  lst.size_ = 0;
932 
933  StorageList::transfer(lst);
934 }
935 
936 
937 template<unsigned nBits>
938 inline unsigned int Foam::PackedList<nBits>::get(const label i) const
939 {
940  // Lazy evaluation - return 0 for out-of-range
941  if (i < 0 || i >= size_)
942  {
943  return 0;
944  }
945  else
946  {
947  return iteratorBase(this, i).get();
948  }
949 }
950 
951 
952 template<unsigned nBits>
953 inline unsigned int Foam::PackedList<nBits>::operator[](const label i) const
954 {
955  // Lazy evaluation - return 0 for out-of-range
956  if (i < 0 || i >= size_)
957  {
958  return 0;
959  }
960  else
961  {
962  return iteratorBase(this, i).get();
963  }
964 }
965 
966 
967 template<unsigned nBits>
969 (
970  const label i,
971  const unsigned int val
972 )
973 {
974  if (i < 0)
975  {
976  // Lazy evaluation - ignore out-of-bounds
977  return false;
978  }
979  else if (i >= size_)
980  {
981  // Lazy evaluation - increase size on assignment
982  resize(i + 1);
983  }
984 
985  return iteratorBase(this, i).set(val);
986 }
987 
988 
989 template<unsigned nBits>
991 {
992  // lazy evaluation - ignore out-of-bounds
993  if (i < 0 || i >= size_)
994  {
995  return false;
996  }
997  else
998  {
999  return iteratorBase(this, i).set(0u);
1000  }
1001 }
1002 
1003 
1004 template<unsigned nBits>
1006 Foam::PackedList<nBits>::append(const unsigned int val)
1007 {
1008  const label elemI = size_;
1009  reserve(elemI + 1);
1010  size_++;
1011 
1012  iteratorBase(this, elemI).set(val);
1013  return *this;
1014 }
1015 
1016 
1017 template<unsigned nBits>
1018 inline unsigned int Foam::PackedList<nBits>::remove()
1019 {
1020  if (!size_)
1021  {
1023  << "List is empty" << abort(FatalError);
1024  }
1025 
1026  label elemI = size_ - 1;
1027  const unsigned int val = iteratorBase(this, elemI).get();
1028  resize(elemI);
1029 
1030  return val;
1031 }
1032 
1033 
1034 template<unsigned nBits>
1037 {
1038  return iteratorBase(this, i);
1039 }
1040 
1041 
1042 template<unsigned nBits>
1043 inline void Foam::PackedList<nBits>::operator=(const unsigned int val)
1044 {
1045  const label packLen = packedLength();
1046 
1047  if (val && size_)
1048  {
1049  unsigned int fill = val;
1050 
1051  if (val >= max_value())
1052  {
1053  // Fill everything
1054  fill = maskLower(packing());
1055  }
1056  else
1057  {
1058  for (unsigned int i = 1; i < packing(); ++i)
1059  {
1060  fill |= (fill << nBits);
1061  }
1062  }
1063 
1064  for (label i=0; i < packLen; ++i)
1065  {
1066  StorageList::operator[](i) = fill;
1067  }
1068 
1069  // Mask off the final partial segment
1070  {
1071  const unsigned int off = size_ % packing();
1072  if (off)
1073  {
1074  const unsigned int seg = size_ / packing();
1075 
1076  StorageList::operator[](seg) &= maskLower(off);
1077  }
1078  }
1079  }
1080  else
1081  {
1082  for (label i=0; i < packLen; ++i)
1083  {
1084  StorageList::operator[](i) = 0u;
1085  }
1086  }
1087 }
1088 
1089 
1090 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:108
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
Istream & readEnd(const char *funcName)
Definition: Istream.C:123
Istream & readBegin(const char *funcName)
Definition: Istream.C:106
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
The const_iterator for PackedList.
Definition: PackedList.H:557
const_iterator & operator--()
Definition: PackedListI.H:601
const_iterator & operator++()
Definition: PackedListI.H:563
The iterator base for PackedList.
Definition: PackedList.H:418
label key() const
Return the element index corresponding to the iterator.
Definition: PackedListI.H:329
bool set(unsigned int) const
Set value, returning true if changed, no range-checking.
Definition: PackedListI.H:302
iteratorBase()
Construct null.
Definition: PackedListI.H:269
label index_
Element index.
Definition: PackedList.H:430
unsigned int get() const
Get value as unsigned, no range-checking.
Definition: PackedListI.H:290
bool writeIfSet(Ostream &) const
Write index/value for a non-zero entry.
Definition: PackedListI.H:146
PackedList * list_
Pointer to original list.
Definition: PackedList.H:427
The iterator class used for PackedList.
Definition: PackedList.H:495
iterator()
Construct null.
Definition: PackedListI.H:397
const iteratorBase & operator()() const
Return iteratorBase for assigning values.
Definition: PackedListI.H:638
const iteratorBase & operator*() const
Return iteratorBase for assigning values.
Definition: PackedListI.H:630
A dynamically allocatable list of packed unsigned integers.
Definition: PackedList.H:153
static unsigned int max_value()
The max. value for an entry, which simultaneously the bit-mask.
Definition: PackedListI.H:38
autoPtr< PackedList< nBits > > clone() const
Clone.
Definition: PackedListI.H:260
void shrink()
Shrink the allocated space to what is actually used.
Definition: PackedListI.H:889
List< unsigned int > & storage()
Return the underlying packed storage.
Definition: PackedListI.H:900
bool set(const label, const unsigned int val=~0u)
Set value at index I. Return true if value changed.
Definition: PackedListI.H:969
static unsigned int maskLower(unsigned offset)
Masking for all bits below the offset.
Definition: PackedListI.H:52
void resize(const label, const unsigned int &val=0u)
Reset addressable list size, does not shrink the allocated size.
Definition: PackedListI.H:710
void setSize(const label, const unsigned int &val=0u)
Alias for resize()
Definition: PackedListI.H:804
void setCapacity(const label)
Alter the size of the underlying storage.
Definition: PackedListI.H:822
label size() const
Number of entries.
Definition: PackedListI.H:695
void transfer(PackedList< nBits > &)
Transfer the contents of the argument list into this list.
Definition: PackedListI.H:928
label capacity() const
The number of elements that can be stored before reallocating.
Definition: PackedListI.H:815
label packedLength() const
The list length when packed.
Definition: PackedListI.H:914
void setPair(Istream &)
Read an index/value pair and set accordingly.
Definition: PackedListI.H:120
iterator end()
Iterator set to beyond the end of the PackedList.
Definition: PackedListI.H:670
bool empty() const
Return true if the list is empty (ie, size() is zero).
Definition: PackedListI.H:702
static unsigned int packing()
The number of entries per packed storage element.
Definition: PackedListI.H:45
const_iterator cend() const
const_iterator set to beyond the end of the PackedList
Definition: PackedListI.H:686
iterator begin()
Iterator set to the beginning of the PackedList.
Definition: PackedListI.H:646
void reserve(const label)
Reserve allocation space for at least this size.
Definition: PackedListI.H:844
unsigned int get(const label) const
Get value at index I.
Definition: PackedListI.H:938
void clearStorage()
Clear the list and delete storage.
Definition: PackedListI.H:881
PackedList()
Null constructor.
Definition: PackedListI.H:168
static unsigned int max_bits()
The max. number of bits that can be templated.
Definition: PackedListI.H:31
const_iterator cbegin() const
const_iterator set to the beginning of the PackedList
Definition: PackedListI.H:662
bool unset(const label)
Unset the entry at index I. Return true if value changed.
Definition: PackedListI.H:990
void operator=(const unsigned int val)
Assignment of all entries to the given value. Takes linear time.
Definition: PackedListI.H:1043
std::streamsize byteSize() const
Return the binary size in number of characters.
Definition: PackedListI.H:921
static unsigned int readValue(Istream &)
Read a list entry (allows for specialisation)
Definition: PackedListI.H:103
PackedList< nBits > & append(const unsigned int val)
Append a value at the end of the list.
Definition: PackedListI.H:1006
void clear()
Clear the list, i.e. set addressable size to zero.
Definition: PackedListI.H:873
unsigned int operator[](const label) const
Get value at index I.
Definition: PackedListI.H:953
void reset()
Clear all bits.
Definition: PackedListI.H:866
unsigned int remove()
Remove and return the last element.
Definition: PackedListI.H:1018
unsigned int StorageType
Definition: PackedList.H:156
A List with indirect addressing.
Definition: UIndirectList.H:61
T * iterator
Random access iterator for traversing UList.
Definition: UList.H:271
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
@ BEGIN_LIST
Definition: token.H:110
@ END_LIST
Definition: token.H:111
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
tUEqn clear()
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
bool readBool(Istream &)
Definition: boolIO.C:63
bool read(const char *, int32_t &)
Definition: int32IO.C:85
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
errorManip< error > abort(error &err)
Definition: errorManip.H:131
IOerror FatalIOError
label readLabel(Istream &is)
Definition: label.H:64
error FatalError
void offset(label &lst, const label o)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
points setSize(newPointi)
triSurfaceToAgglom resize(surfacesMesh.size())
Template-invariant bits for PackedList.
Definition: PackedList.H:134