32template<
unsigned W
idth>
41 const label len = addr.
size();
43 for (label i = 0; i < len; ++i)
50template<
unsigned W
idth>
54 const PackedList<Width>& list,
55 const IndirectListBase<label, Addr>& addr
58 PackedList<Width>(addr.size())
60 const label len = addr.size();
62 for (label i = 0; i < len; ++i)
64 set(i, list.get(addr[i]));
69template<
unsigned W
idth>
72 const PackedList<Width>& list,
73 const labelRange&
range
76 PackedList<Width>(
range.size())
79 const label len =
range.size();
81 for (label i = 0; i < len; ++i)
91template<
unsigned W
idth>
105 const unsigned int val =
get(0);
107 bool identical =
true;
113 identical = (-1 == first_block());
119 identical = (-1 == first_not_block());
123 const label nblocks = num_blocks(size());
128 const unsigned int blockval = repeated_value(val);
131 for (label blocki = 0; identical && blocki < (nblocks-1); ++blocki)
133 identical = (blocks_[blocki] == blockval);
140 label elemi = elem_per_block*(nblocks-1);
141 identical && elemi < size();
145 identical = (val ==
get(elemi));
153template<
unsigned W
idth>
156 if (size() != other.size())
161 const label nblocks = num_blocks(size());
162 const auto&
rhs = other.blocks_;
164 for (label blocki = 0; blocki < nblocks; ++blocki)
166 if (blocks_[blocki] !=
rhs[blocki])
176template<
unsigned W
idth>
183template<
unsigned W
idth>
184template<
class IntType>
190 std::is_integral_v<IntType>,
191 "Integral required for output."
195 Width < std::numeric_limits<IntType>::digits,
196 "Width of IntType is too small to hold result"
207 output =
static_cast<IntType
>(get(0));
216 const label nblocks = num_blocks(size());
218 for (label blocki=0; blocki < nblocks-1; ++blocki)
220 unsigned int blockval = blocks_[blocki];
222 for (
unsigned nget = elem_per_block; nget; --nget, ++outi)
230 for (; outi < size(); ++outi)
232 output[outi] =
get(outi);
239template<
unsigned W
idth>
240template<
class IntType>
246 std::is_integral_v<IntType>,
247 "Integral required for unpack output."
251 Width < std::numeric_limits<IntType>::digits,
252 "Width of IntType is too small to hold unpack output."
263 for (IntType& out : output)
265 out = IntType(get(
pos));
273template<
unsigned W
idth>
274template<
class IntType>
280 std::is_integral_v<IntType>,
281 "Integral required for unpack output."
285 Width < std::numeric_limits<IntType>::digits,
286 "Width of IntType is too small to hold unpack output."
294 for (IntType& out : output)
296 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 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
label first_block() const
Find the first block with a '1' bit.
bool equal(const PackedList< Width > &other) const
Test for equality of sizes and the bits set.
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.
List< IntType > unpack() const
Return the values as a list of integral type.
static constexpr block_type max_value
The max value for an element which is also the bit-mask of the individual element.
static unsigned int repeated_value(unsigned val)
Enforce non-zero Width to fit within the block storage and require at least 2 items per storage block...
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.
static constexpr unsigned elem_per_block
The number of elements stored per data block.
static constexpr label num_blocks(label numElem) noexcept
Calculate the number of blocks required to _address_ the requested number of elements.
label size() const noexcept
Number of entries.
label first_not_block() const
Find the first block with a '0' bit.
Foam::List< IntType > unpack() const
void size(const label n)
Older name for setAddressableSize.
A range or interval of labels defined by a start and a size.
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
dimensionedScalar pos(const dimensionedScalar &ds)
List< label > labelList
A List of labels.
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
UList< label > labelUList
A UList of labels.