30 template<
unsigned nBits>
37 template<
unsigned nBits>
40 return (1u << nBits) - 1;
44 template<
unsigned nBits>
51 template<
unsigned nBits>
57 return (~0u >> (
sizeof(
StorageType)*CHAR_BIT - nBits * offset));
61 template<
unsigned nBits>
64 return (nElem + packing() - 1) / packing();
102 template<
unsigned nBits>
107 if (val > max_value())
110 <<
"Out-of-range value " << val <<
" for PackedList<" << nBits
111 <<
">. Maximum permitted value is " << max_value() <<
"." 119 template<
unsigned nBits>
122 is.
readBegin(
"Tuple2<label, unsigned int>");
127 is.
readEnd(
"Tuple2<label, unsigned int>");
129 if (val > max_value())
132 <<
"Out-of-range value " << val <<
" for PackedList<" << nBits
133 <<
"> at index " << ind
134 <<
". Maximum permitted value is " << max_value() <<
"." 141 is.
check(
"PackedList<nBits>::setPair(Istream&)");
145 template<
unsigned nBits>
148 const label val = this->
get();
167 template<
unsigned nBits>
176 template<
unsigned nBits>
185 template<
unsigned nBits>
189 const unsigned int val
203 template<
unsigned nBits>
214 template<
unsigned nBits>
223 template<
unsigned nBits>
230 template<
unsigned nBits>
244 template<
unsigned nBits>
258 template<
unsigned nBits>
268 template<
unsigned nBits>
276 template<
unsigned nBits>
288 template<
unsigned nBits>
295 const unsigned int& stored =
list_->StorageList::operator[](seg);
296 return (stored >> (nBits * off)) &
max_value();
300 template<
unsigned nBits>
307 const unsigned int startBit = nBits * off;
308 const unsigned int mask =
max_value() << startBit;
310 unsigned int& stored =
list_->StorageList::operator[](seg);
311 const unsigned int prev = stored;
321 stored |= mask & (val << startBit);
324 return prev != stored;
328 template<
unsigned nBits>
335 template<
unsigned nBits>
341 return this->
get() == iter.
get();
345 template<
unsigned nBits>
346 inline bool Foam::PackedList<nBits>::iteratorBase::operator!=
351 return this->
get() != iter.
get();
355 template<
unsigned nBits>
356 inline void Foam::PackedList<nBits>::iteratorBase::operator=
361 const unsigned int val = iter.
get();
366 template<
unsigned nBits>
367 inline void Foam::PackedList<nBits>::iteratorBase::operator=
369 const unsigned int val
382 template<
unsigned nBits>
383 inline Foam::PackedList<nBits>::iteratorBase::operator
384 unsigned int ()
const 396 template<
unsigned nBits>
403 template<
unsigned nBits>
410 template<
unsigned nBits>
427 template<
unsigned nBits>
444 template<
unsigned nBits>
455 template<
unsigned nBits>
466 template<
unsigned nBits>
476 template<
unsigned nBits>
477 inline bool Foam::PackedList<nBits>::iterator::operator==
486 template<
unsigned nBits>
487 inline bool Foam::PackedList<nBits>::iterator::operator!=
496 template<
unsigned nBits>
497 inline bool Foam::PackedList<nBits>::const_iterator::operator==
506 template<
unsigned nBits>
507 inline bool Foam::PackedList<nBits>::const_iterator::operator!=
516 template<
unsigned nBits>
517 inline void Foam::PackedList<nBits>::iterator::operator=
534 template<
unsigned nBits>
535 inline void Foam::PackedList<nBits>::const_iterator::operator=
552 template<
unsigned nBits>
561 template<
unsigned nBits>
570 template<
unsigned nBits>
580 template<
unsigned nBits>
590 template<
unsigned nBits>
599 template<
unsigned nBits>
608 template<
unsigned nBits>
618 template<
unsigned nBits>
628 template<
unsigned nBits>
636 template<
unsigned nBits>
644 template<
unsigned nBits>
652 template<
unsigned nBits>
660 template<
unsigned nBits>
668 template<
unsigned nBits>
676 template<
unsigned nBits>
684 template<
unsigned nBits>
692 template<
unsigned nBits>
700 template<
unsigned nBits>
710 template<
unsigned nBits>
717 template<
unsigned nBits>
724 template<
unsigned nBits>
728 const unsigned int& val
733 const label oldSize = size_;
742 unsigned int fill = val;
751 for (
unsigned int i = 1; i <
packing(); ++i)
753 fill |= (fill << nBits);
760 for (
label i=oldLen; i < newLen; ++i)
767 const unsigned int off = oldSize %
packing();
770 const unsigned int seg = oldSize /
packing();
771 const unsigned int mask =
maskLower(off);
781 const unsigned int off = size_ %
packing();
784 const unsigned int seg = size_ /
packing();
791 else if (size_ < oldSize)
799 for (
label i=newLen; i < oldLen; ++i)
806 const unsigned int off = size_ %
packing();
809 const unsigned int seg = size_ /
packing();
818 template<
unsigned nBits>
822 const unsigned int& val
830 template<
unsigned nBits>
837 template<
unsigned nBits>
848 const unsigned int off = size_ %
packing();
851 const unsigned int seg = size_ /
packing();
859 template<
unsigned nBits>
881 template<
unsigned nBits>
888 template<
unsigned nBits>
896 template<
unsigned nBits>
904 template<
unsigned nBits>
915 template<
unsigned nBits>
922 template<
unsigned nBits>
929 template<
unsigned nBits>
936 template<
unsigned nBits>
943 template<
unsigned nBits>
953 template<
unsigned nBits>
957 if (i < 0 || i >= size_)
968 template<
unsigned nBits>
972 if (i < 0 || i >= size_)
983 template<
unsigned nBits>
987 const unsigned int val
1005 template<
unsigned nBits>
1009 if (i < 0 || i >= size_)
1020 template<
unsigned nBits>
1024 const label elemI = size_;
1033 template<
unsigned nBits>
1042 label elemI = size_ - 1;
1043 const unsigned int val =
iteratorBase(
this, elemI).get();
1050 template<
unsigned nBits>
1058 template<
unsigned nBits>
1065 unsigned int fill = val;
1074 for (
unsigned int i = 1; i <
packing(); ++i)
1076 fill |= (fill << nBits);
1080 for (
label i=0; i < packLen; ++i)
1087 const unsigned int off = size_ %
packing();
1090 const unsigned int seg = size_ /
packing();
1098 for (
label i=0; i < packLen; ++i)
Istream & readBegin(const char *funcName)
const_iterator & operator--()
The iterator class used for PackedList.
#define forAll(list, i)
Loop across all elements in list.
label key() const
Return the element index corresponding to the iterator.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
unsigned int operator[](const label) const
Get value at index I.
unsigned int operator()() const
Return referenced value directly.
errorManipArg< error, int > exit(error &err, const int errNo=1)
unsigned int get(const label) const
Get value at index I.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
T & operator[](const label)
Return element of UList.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
unsigned int get() const
Get value as unsigned, no range-checking.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
bool set(unsigned int)
Set value, returning true if changed, no range-checking.
iterator begin()
Iterator set to the beginning of the PackedList.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
void setCapacity(const label)
Alter the size of the underlying storage.
label index_
Element index.
bool set(const label, const unsigned int val=~0u)
Set value at index I. Return true if value changed.
void reserve(const label)
Reserve allocation space for at least this size.
unsigned int remove()
Remove and return the last element.
T * iterator
Random access iterator for traversing UList.
bool writeIfSet(Ostream &) const
Write index/value for a non-zero entry.
unsigned int operator()() const
Return value.
static unsigned int max_bits()
The max. number of bits that can be templated.
std::streamsize byteSize() const
Return the binary size in number of characters.
void transfer(PackedList< nBits > &)
Transfer the contents of the argument list into this list.
iteratorBase()
Construct null.
Istream & readEnd(const char *funcName)
label packedLength() const
The list length when packed.
A dynamically allocatable list of packed unsigned integers.
void clear()
Clear the list, i.e. set size to zero.
static unsigned int readValue(Istream &)
Read a list entry (allows for specialisation)
unsigned int operator*() const
Return value.
bool unset(const label)
Unset the entry at index I. Return true if value changed.
static unsigned int maskLower(unsigned offset)
Masking for all bits below the offset.
PackedList()
Null constructor.
static unsigned int packing()
The number of entries per packed storage element.
void setSize(const label, const unsigned int &val=0u)
Alias for resize()
errorManip< error > abort(error &err)
void clear()
Clear the list, i.e. set addressable size to zero.
label readLabel(Istream &is)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Template-invariant bits for PackedList.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
void resize(const label, const unsigned int &val=0u)
Reset addressable list size, does not shrink the allocated size.
PackedList< nBits > & append(const unsigned int val)
Append a value at the end of the list.
The const_iterator for PackedList.
The iterator base for PackedList.
iterator end()
Iterator set to beyond the end of the PackedList.
static unsigned int max_value()
The max. value for an entry, which simultaneously the bit-mask.
void operator=(const UList< T > &)
Assignment to UList operator. Takes linear time.
iterator()
Construct null.
void setSize(const label)
Reset size of List.
List< unsigned int > & storage()
Return the underlying packed storage.
void operator=(const unsigned int val)
Assignment of all entries to the given value. Takes linear time.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
label capacity() const
The number of elements that can be stored before reallocating.
A List with indirect addressing.
bool empty() const
Return true if the list is empty (ie, size() is zero).
void clearStorage()
Clear the list and delete storage.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
label size() const
Number of entries.
void reset()
Clear all bits.
void setPair(Istream &)
Read an index/value pair and set accordingly.
const_iterator cend() const
const_iterator set to beyond the end of the PackedList
void shrink()
Shrink the allocated space to what is actually used.
const_iterator()
Construct null.
label size() const
Return the number of elements in the UList.
PackedList * list_
Pointer to original list.
const_iterator & operator++()
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
autoPtr< PackedList< nBits > > clone() const
Clone.
const_iterator cbegin() const
const_iterator set to the beginning of the PackedList
unsigned int operator*() const
Return referenced value directly.