33template<
unsigned W
idth>
42 const label len = addr.
size();
44 for (label i = 0; i < len; ++i)
51template<
unsigned W
idth>
61 const label len = addr.
size();
63 for (label i = 0; i < len; ++i)
70template<
unsigned W
idth>
80 const label len =
range.size();
82 for (label i = 0; i < len; ++i)
92template<
unsigned W
idth>
100 else if (size() == 1)
107 const unsigned int val = get(0);
109 const label nblocks = num_blocks(size());
111 bool identical =
true;
117 for (label blocki = 0; identical && blocki < nblocks; ++blocki)
119 identical = !blocks_[blocki];
124 else if (nblocks > 1)
127 const unsigned int blockval = repeated_value(val);
130 for (label blocki = 0; identical && blocki < (nblocks-1); ++blocki)
132 identical = (blocks_[blocki] == blockval);
139 label elemi = elem_per_block*(nblocks-1);
140 identical && elemi < size();
144 identical = (val == get(elemi));
151template<
unsigned W
idth>
154 if (size() != other.
size())
159 const label nblocks = num_blocks(size());
160 const auto& rhs = other.
blocks_;
162 for (label blocki = 0; blocki < nblocks; ++blocki)
164 if (blocks_[blocki] != rhs[blocki])
174template<
unsigned W
idth>
177 return this->unpack<label>();
181template<
unsigned W
idth>
182template<
class IntType>
188 std::is_integral<IntType>::value,
189 "Integral required for output."
193 std::numeric_limits<IntType>::digits >= Width,
194 "Width of IntType is too small to hold result"
210 const label nblocks = num_blocks(size());
212 for (label blocki=0; blocki < nblocks-1; ++blocki)
214 unsigned int blockval = blocks_[blocki];
216 for (
unsigned nget = elem_per_block; nget; --nget, ++outi)
218 output[outi] = IntType(blockval & max_value);
224 for (; outi < size(); ++outi)
233template<
unsigned W
idth>
234template<
class IntType>
240 std::is_integral<IntType>::value,
241 "Integral required for unpack output."
245 std::numeric_limits<IntType>::digits >= Width,
246 "Width of IntType is too small to hold unpack output."
257 for (IntType& out :
output)
259 out = IntType(get(
pos));
267template<
unsigned W
idth>
268template<
class IntType>
274 std::is_integral<IntType>::value,
275 "Integral required for unpack output."
279 std::numeric_limits<IntType>::digits >= Width,
280 "Width of IntType is too small to hold unpack output."
288 for (IntType& out :
output)
290 out = IntType(get(locations[
pos]));
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
label size() const noexcept
The number of elements in the list.
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
bool equal(const PackedList< Width > &other) const
Test for equality of sizes and the bits set.
block_container blocks_
The blocks of raw data.
labelList values() const
Return the values as a list of labels.
List< IntType > unpack() const
Return the values as a list of integral type.
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.
bool uniform() const
True if all entries have identical values, and list is non-empty.
unsigned int get(const label i) const
Get value at index i or 0 for out-of-range.
constexpr PackedList() noexcept
Default construct, zero-sized and no allocation.
void size(const label n)
Older name for setAddressableSize.
A range or interval of labels defined by a start and a size.
dimensionedScalar pos(const dimensionedScalar &ds)
static Ostream & output(Ostream &os, const IntRange< T > &range)