33template<
unsigned W
idth>
36 return BitOps::repeat_value<block_type,Width>(val);
40template<
unsigned W
idth>
48 <<
"Out-of-range value " << val <<
" for PackedList<" << Width
49 <<
">. Maximum permitted value is " << max_value <<
"."
57template<
unsigned W
idth>
65 is.
readEnd(
"Tuple2<label,uint32>");
70 <<
"Out-of-range value " << val <<
" for PackedList<" << Width
71 <<
"> at index " << ind
72 <<
". Maximum permitted value is " << max_value <<
"."
82template<
unsigned W
idth>
86 const unsigned int blk = size() / elem_per_block;
87 const unsigned int off = size() % elem_per_block;
91 blocks_[blk] &= mask_lower(off);
96template<
unsigned W
idth>
104 const label orig = size();
110 for (label blocki = num_blocks(size())-1; blocki >= 0; --blocki)
113 size_ = blocki * elem_per_block;
115 unsigned int blockval = blocks_[blocki];
120 for (; blockval; ++size_)
126 else if (size_ < minpos)
137 return (size() != orig);
141template<
unsigned W
idth>
158 return (val ? ~0u : 0u);
176template<
unsigned W
idth>
184template<
unsigned W
idth>
187 blocks_(num_blocks(numElem), 0u),
192template<
unsigned W
idth>
196 const unsigned int val
199 blocks_(num_blocks(numElem), 0u),
209template<
unsigned W
idth>
219template<
unsigned W
idth>
222 blocks_(list.blocks_),
227template<
unsigned W
idth>
230 blocks_(std::move(list.blocks_)),
237template<
unsigned W
idth>
240 blocks_(num_blocks(values.size()), 0u),
243 const label len = values.size();
248 for (label i = 0; i < len; ++i)
250 const unsigned int val(values[i]);
251 if (val) set(i, val);
256template<
unsigned W
idth>
263 blocks_(num_blocks(values.size()), 0u),
271 for (label i = 0; i < len; ++i)
273 const unsigned int val(
values[i]);
274 if (val)
set(i, val);
279template<
unsigned W
idth>
289template<
unsigned W
idth>
296 ref_(parent->blocks_[index / elem_per_block]),
297 shift_(Width * (index % elem_per_block))
301template<
unsigned W
idth>
308template<
unsigned W
idth>
311 const unsigned int mask = (
max_value << shift_);
312 const unsigned int prev = ref_;
321 ref_ |= mask & (val << shift_);
324 return (prev != ref_);
328template<
unsigned W
idth>
335 this->
set(other.get());
339template<
unsigned W
idth>
342 const unsigned int val
349template<
unsigned W
idth>
358template<
unsigned W
idth>
364 <<
"attempt to access element " << i <<
" from zero sized list"
370 <<
"index " << i <<
" out of range [0," <<
size_ <<
")"
376template<
unsigned W
idth>
383template<
unsigned W
idth>
390template<
unsigned W
idth>
397template<
unsigned W
idth>
407template<
unsigned W
idth>
411 const unsigned int val
416 const label oldSize =
size();
419 if (oldSize < newSize)
430 for (label blocki = oldLen; blocki < newLen; ++blocki)
444 blocks_[blk] |= ~mask & blockval;
451 else if (newSize < oldSize)
460 for (label blocki = newLen; blocki < oldLen; ++blocki)
470template<
unsigned W
idth>
477 if (numElem <
size())
485template<
unsigned W
idth>
504template<
unsigned W
idth>
511template<
unsigned W
idth>
519template<
unsigned W
idth>
527template<
unsigned W
idth>
539template<
unsigned W
idth>
546template<
unsigned W
idth>
553template<
unsigned W
idth>
560template<
unsigned W
idth>
567template<
unsigned W
idth>
574template<
unsigned W
idth>
581template<
unsigned W
idth>
588template<
unsigned W
idth>
595template<
unsigned W
idth>
602template<
unsigned W
idth>
615template<
unsigned W
idth>
629template<
unsigned W
idth>
632 if (i < 0 || i >=
size())
638 <<
"Ignoring attempt to get a negative index " << i
639 <<
" range is [0," <<
size_ <<
")"
651template<
unsigned W
idth>
655 const unsigned int val
662 <<
"Ignoring attempt to set a negative index " << i
663 <<
" range is [0," <<
size_ <<
")"
669 else if (i >=
size())
683template<
unsigned W
idth>
686 if (i < 0 || i >=
size())
695template<
unsigned W
idth>
699 const label idx =
size();
708template<
unsigned W
idth>
712 const label idx =
size()-1;
727template<
unsigned W
idth>
740 for (label blocki=0; blocki < nblocks; ++blocki)
754template<
unsigned W
idth>
761template<
unsigned W
idth>
772template<
unsigned W
idth>
779template<
unsigned W
idth>
786template<
unsigned W
idth>
795template<
unsigned W
idth>
796inline bool Foam::operator==
806template<
unsigned W
idth>
807inline bool Foam::operator!=
virtual bool resize()
Resize the ODE solver.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
bool readEnd(const char *funcName)
End read of data chunk, ends with ')'.
bool readBegin(const char *funcName)
Begin read of data chunk, starts with '('.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(List< T > &list)
void resize(const label len)
Adjust allocated size of list.
void clear()
Clear the list, i.e. set size to zero.
virtual char fill() const =0
Get padding character.
A reference supporting read/write access to an entry.
unsigned shift_
The bit shift to access the given sub-portion.
block_type & ref_
Reference to the block.
unsigned int get() const
Get value as unsigned, no range-checking.
bool set(unsigned int val)
Set value, returning true if changed, no range-checking.
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
void copyAssign(const PackedList< Width > &rhs)
Copy assignment.
void shrink()
Shrink the allocated space to what is actually used.
label size_
Number of entries used.
static unsigned int readValue(Istream &is)
Read a list entry (allows for specialization)
void swap(PackedList< Width > &rhs)
Swap contents with argument.
char * data_bytes() noexcept
A pointer to the raw storage, reinterpreted as byte data.
void checkIndex(const label i) const
Check index is within valid range [0,size)
const unsigned int * cdata() const noexcept
A const pointer to the raw storage.
bool equal(const PackedList< Width > &other) const
Test for equality of sizes and the bits set.
static constexpr block_type mask_lower(unsigned elementOffset)
Masking for all bits below the element offset.
block_container blocks_
The blocks of raw data.
bool empty() const noexcept
True if the list is empty (ie, size() is zero).
labelList values() const
Return the values as a list of labels.
void resize_nocopy(const label numElem)
Currently identical to resize. Subject to future change (Oct-2021)
autoPtr< PackedList< Width > > clone() const
Clone.
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
void fill(const unsigned int val)
Assign all entries to the given value.
static constexpr block_type max_value
static unsigned int repeated_value(unsigned val)
A fill value for complete blocks.
void setCapacity(const label numElem)
Alter the size of the underlying storage.
void clear_trailing_bits()
Clear any partial rubbish in the last addressable block.
std::streamsize byteSize() const noexcept
label nBlocks() const
The number of internal storage blocks.
void clearStorage()
Clear the list and delete storage.
label capacity() const noexcept
The number of elements that can be stored with reallocating.
label size() const noexcept
Number of entries.
bool set(const label i, unsigned int val=~0u)
Set value at index i, default value set is the max_value.
void reserve(const label numElem)
unsigned int get(const label i) const
Get value at index i or 0 for out-of-range.
void operator=(const PackedList< Width > &lst)
Copy assignment.
constexpr PackedList() noexcept
Default construct, zero-sized and no allocation.
static constexpr unsigned elem_per_block
The number of elements stored per data block.
unsigned int * data() noexcept
A pointer to the raw storage.
void transfer(PackedList< Width > &rhs)
const char * cdata_bytes() const noexcept
A const pointer to the raw storage, reinterpreted as byte data.
const List< unsigned int > & storage() const
Return the underlying storage blocks.
static constexpr label num_blocks(label numElem) noexcept
void setPair(Istream &is)
Read an index/value pair and set accordingly.
unsigned int block_type
The storage block type for bit elements.
void clear()
Clear the list, i.e. set addressable size to zero.
void reset()
Clear all bits but do not adjust the addressable size.
std::streamsize size_bytes() const noexcept
unsigned int operator[](const label i) const
Identical to get() - get value at index.
unsigned int remove()
Remove and return the last element.
void swap(UList< T > &list)
Swap content with another UList of the same type in constant time.
char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage,.
const T * cdata() const noexcept
Return pointer to the underlying array serving as data storage.
T * data() noexcept
Return pointer to the underlying array serving as data storage.
const char * cdata_bytes() const noexcept
Return pointer to the underlying array serving as data storage,.
void size(const label n)
Older name for setAddressableSize.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void trim()
Inplace trim leading and trailing whitespace.
Computes a field whose values are offset to a reference value obtained by from a Function1.
transferModelList & transfer()
Transfer.
bool set() const
Are all the vector set.
bool append() const noexcept
True if output format uses an append mode.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool readBool(Istream &is)
Read bool from stream using Foam::Switch(Istream&)