33 template<
unsigned W
idth>
42 const label len = addr.
size();
44 for (label i = 0; i < len; ++i)
46 set(i, list.
get(addr[i]));
51 template<
unsigned W
idth>
55 const PackedList<Width>& list,
56 const IndirectListBase<label, Addr>& addr
59 PackedList<Width>(addr.size())
61 const label len = addr.size();
63 for (label i = 0; i < len; ++i)
65 set(i, list.get(addr[i]));
70 template<
unsigned W
idth>
73 const PackedList<Width>& list,
74 const labelRange&
range 77 PackedList<Width>(
range.size())
80 const label len =
range.size();
82 for (label i = 0; i < len; ++i)
84 set(i, list.get(
pos));
92 template<
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));
151 template<
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])
174 template<
unsigned W
idth>
177 return this->unpack<label>();
181 template<
unsigned W
idth>
182 template<
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" 203 return List<IntType>(size(),
static_cast<IntType
>(
get(0)));
206 List<IntType>
output(size());
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)
233 template<
unsigned W
idth>
234 template<
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));
267 template<
unsigned W
idth>
268 template<
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]));
void size(const label n)
Older name for setAddressableSize.
A range or interval of labels defined by a start and a size.
List< IntType > unpack() const
Return the values as a list of integral type.
bool uniform() const
True if all entries have identical values, and list is non-empty.
dimensionedScalar pos(const dimensionedScalar &ds)
constexpr PackedList() noexcept
Default construct, zero-sized and no allocation.
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
labelList values() const
Return the values as a list of labels.
static Ostream & output(Ostream &os, const IntRange< T > &range)
bool equal(const PackedList< Width > &other) const
Test for equality of sizes and the bits set.
unsigned int get(const label i) const
Get value at index i or 0 for out-of-range.