35inline void Foam::CompactListList<T>::enforceSizeSanity()
37 if (offsets_.size() == 1)
53 const CompactListList<T>& list
56 offsets_(list.offsets_),
67 offsets_(std::move(list.offsets_)),
68 values_(std::move(list.values_))
79 offsets_(list.offsets_, reuse),
80 values_(list.values_, reuse)
141 return values_.cdata();
148 return values_.data();
155 return values_.cdata_bytes();
162 return values_.data_bytes();
169 return values_.size_bytes();
179 return (offsets_.size() <= 1);
186 return (offsets_.size() == 2);
193 const label len = (offsets_.size() - 1);
194 return (len < 1) ?
static_cast<label
>(0) : len;
201 const label len = (offsets_.size() - 1);
202 return (len < 1) ?
static_cast<label
>(0) : len;
216 return offsets_.empty() ? 0 : *(offsets_.cdata() + offsets_.size()-1);
223 return this->maxNonLocalSize(-1);
231 const label len = (offsets_.size() - 1);
249 return offsets_[i+1];
256 return offsets_[i+1] - offsets_[i];
264 return SubList<T>(values_, (offsets_[i+1] - offsets_[i]), offsets_[i]);
272 return SubList<T>(values_, (offsets_[i+1] - offsets_[i]), offsets_[i]);
283 return i + offsets_[rowi];
294 const label locali = i - offsets_[rowi];
296 if (locali < 0 || i >= offsets_[rowi+1])
299 <<
"Index " << i <<
" does not belong on row "
300 << rowi <<
nl <<
"Offsets:" << offsets_
318 const label rowi = findRow(i);
323 <<
"Index " << i <<
" outside of range" <<
nl
324 <<
"Offsets:" << offsets_
349 else if (mRows < size())
352 offsets_.resize(mRows+1);
353 values_.resize(offsets_[mRows]);
355 else if (mRows > size())
358 const label endOffset = offsets_.empty() ? 0 : offsets_.back();
360 offsets_.resize(mRows+1, endOffset);
381 values_.resize(nVals);
402 values_.resize_nocopy(nVals);
424 values_.resize(nVals, val);
434 const CompactListList<T>& list
442 offsets_ = list.offsets_,
443 values_ = list.values_;
458 offsets_.transfer(list.offsets_);
459 values_.transfer(list.values_);
513 return values_[toGlobal(i, j)];
Various functions to operate on Lists.
A packed storage of objects of type <T> using an offset table for access.
const SubList< T > operator[](const label i) const
Return const access to sub-list (no subscript checking).
bool single() const noexcept
True if content is a single row/sublist only. Such content could be flattened out into a straight lis...
label maxSize() const
The max row length used.
void resize_nocopy(const label mRows, const label nVals)
Redimension without preserving existing content.
char * data_bytes() noexcept
Return pointer to underlying values storage, reinterpreted as byte data.
label localSize(const label i) const
Size of given row.
label totalSize() const noexcept
The total addressed size, which corresponds to the end (back) offset and also the sum of all localSiz...
bool empty() const noexcept
True if the number of rows/sublists is zero.
const T * cdata() const noexcept
Return const pointer to the first data in values().
label whichRow(const label i) const
Which row does global index come from? Binary search.
label findRow(const label i) const
Find row where global index comes from. Binary search.
const labelUList localStarts() const
The local row starts.
label length() const noexcept
The primary size (the number of rows/sublists).
label localStart(const label i) const
Starting offset for given row.
label size() const noexcept
The primary size (the number of rows/sublists).
void operator=(const CompactListList< T > &list)
Copy assignment.
T * data() noexcept
Return pointer to the first data in values().
const SubList< T > localList(const label i) const
Return const access to sub-list (no subscript checking).
labelList sizes() const
The local row sizes. Same as localSizes.
void resize(const label mRows)
Reset size of CompactListList.
const char * cdata_bytes() const noexcept
Return const pointer to underlying values storage, reinterpreted as byte data.
labelList localSizes() const
The local row sizes.
label localEnd(const label i) const
End offset (exclusive) for given row.
void clear()
Clear addressing and contents.
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the values data, no runtime check that the type is actually contiguous...
label toLocal(const label rowi, const label i) const
From global to local index on rowi.
CompactListList() noexcept=default
Default construct.
autoPtr< CompactListList< T > > clone() const
Clone.
label toGlobal(const label rowi, const label i) const
From local index on rowi to global (flat) indexing into packed values.
A non-owning sub-view of a List (allocated or unallocated storage).
static const UList< label > & null() noexcept
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
List< label > labelList
A List of labels.
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
Binary search to find the index of the last element in a sorted list that is less than value.
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
UList< label > labelUList
A UList of labels.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
constexpr char nl
The newline '\n' character (0x0a).