42 <<
"Overflow : sum of sizes exceeds labelMax (" 43 <<
labelMax <<
") after index " << idx;
45 if (!localLens.empty())
52 <<
"Please recompile with larger datatype for label." <<
nl 58 template<
class ListListType>
61 const ListListType& lists,
62 const bool checkOverflow
67 auto& newOffsets = compact.offsets_;
68 auto& newValues = compact.values_;
71 const label len = lists.size();
75 newOffsets.resize(len+1,
Zero);
77 for (label i = 0; i < len; ++i)
79 newOffsets[i] = total;
80 total += lists[i].size();
82 if (checkOverflow && total < newOffsets[i])
84 reportOverflowAndExit(i);
87 newOffsets[len] = total;
93 newValues.resize(total);
95 auto outIter = newValues.begin();
97 for (
const auto& list : lists)
112 template<
class SubListType>
116 const bool checkOverflow
128 template<
class SubListType,
class Addr>
132 const bool checkOverflow
148 const label len = listSizes.
size();
152 offsets_.resize(len+1);
155 for (label i = 0; i < len; ++i)
158 total += listSizes[i];
161 if (total < offsets_[i])
163 reportOverflowAndExit(i, listSizes);
168 offsets_[len] = total;
169 values_.resize(total);
181 const label len = listSizes.size();
185 offsets_.resize(len+1);
188 for (label i = 0; i < len; ++i)
191 total += listSizes[i];
194 if (total < offsets_[i])
196 reportOverflowAndExit(i, listSizes);
201 offsets_[len] = total;
202 values_.resize(total, val);
212 const label len = (offsets_.size() - 1);
221 for (label i=0; i < len; ++i)
225 const label localLen = (offsets_[i+1] - offsets_[i]);
226 maxLen =
max(maxLen, localLen);
237 if (!is_contiguous<T>::value)
240 <<
"Invalid for non-contiguous data types" 243 return this->size_bytes();
250 return labelRange(offsets_[i], offsets_[i+1] - offsets_[i]);
260 const label len = (offsets_.size() - 1);
269 for (label i=0; i < len; ++i)
271 values[i].reset(offsets_[i], (offsets_[i+1] - offsets_[i]));
281 const label len = listSizes.size();
285 offsets_.resize(len+1);
288 for (label i = 0; i < len; ++i)
291 total += listSizes[i];
293 if (checkOverflow && total < offsets_[i])
295 reportOverflowAndExit(i, listSizes);
300 offsets_[len] = total;
301 values_.resize(total);
313 if (rowi >= 0 && rowi+1 < offsets_.size() && len >= 0)
315 const label
delta = (len - (offsets_[rowi+1] - offsets_[rowi]));
320 for (label i = rowi+1; i < offsets_.size(); ++i)
322 offsets_[i] +=
delta;
334 const label len = (offsets_.size() - 1);
343 for (label i=0; i < len; ++i)
345 values[i] = offsets_[i+1] - offsets_[i];
363 offsets_.swap(other.offsets_);
364 values_.swap(other.values_);
379 offsets_.transfer(list.offsets_);
380 values_.transfer(list.values_);
385 template<
class SubListType>
393 lists[i] = SubListType(this->localList(i));
401 template<
class SubListType>
407 auto outIter = lists.
begin();
409 for (
const label i :
range)
411 *outIter = SubListType(this->localList(i));
void size(const label n)
Older name for setAddressableSize.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
A range or interval of labels defined by a start and a size.
constexpr char nl
The newline '\n' character (0x0a)
void swap(CompactListList< T > &other)
Swap contents.
static CompactListList< T > pack(const UList< SubListType > &lists, const bool checkOverflow=false)
Construct by packing together the list of lists.
Base for lists with indirect addressing, templated on the list contents type and the addressing type...
UList< label > labelUList
A UList of labels.
void transfer(CompactListList< T > &list)
Transfer contents into this and annul the argument.
#define forAll(list, i)
Loop across all elements in list.
void setLocalSize(const label rowi, const label len)
Alter local addressing size for given row, does not change content.
List< labelRange > ranges() const
Return start/size ranges for all sub-lists.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
List< SubListType > unpack() const
Return non-compact list of lists.
labelRange range(const label i) const
Return start/size range for given sub-list.
CompactListList() noexcept=default
Default construct.
void resize(const label mRows)
Reset size of CompactListList.
errorManip< error > abort(error &err)
iterator begin() noexcept
Return an iterator to begin traversing the UList.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
std::streamsize byteSize() const
Number of contiguous bytes for the values data, runtime FatalError if type is not contiguous...
A packed storage unstructured matrix of objects of type <T> using an offset table for access...
labelList localSizes() const
The local row sizes.
List< label > labelList
A List of labels.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
static constexpr const zero Zero
Global zero (0)