37 if (offsets_.size() == 1)
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_
311 return (i < 0 || i >= totalSize()) ? -1 :
findLower(offsets_, i+1);
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);
442 offsets_ = list.offsets_,
443 values_ = list.values_;
459 values_.transfer(list.values_);
482 return this->localList(i);
491 return this->localList(i);
502 return values_[toGlobal(i, j)];
513 return values_[toGlobal(i, j)];
label localStart(const label i) const
Starting offset for given row.
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...
label toLocal(const label rowi, const label i) const
From global to local index on rowi.
bool empty() const noexcept
True if the number of rows/sublists is zero.
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the values data, no runtime check that the type is actually contiguous...
label size() const noexcept
The primary size (the number of rows/sublists)
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.
label toGlobal(const label rowi, const label i) const
From local index on rowi to global (flat) indexing into packed values.
constexpr char nl
The newline '\n' character (0x0a)
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.
char * data_bytes() noexcept
Return pointer to underlying values storage, reinterpreted as byte data.
SubList< label > subList
Declare type of subList.
void clear()
Clear addressing and contents.
label localSize(const label i) const
Size of given row.
void transfer(CompactListList< T > &list)
Transfer contents into this and annul the argument.
Various functions to operate on Lists.
const char * cdata_bytes() const noexcept
Return const pointer to underlying values storage, reinterpreted as byte data.
label findRow(const label i) const
Find row where global index comes from. Binary search.
A List obtained as a section of another List.
label localEnd(const label i) const
End offset (exclusive) for given row.
autoPtr< CompactListList< T > > clone() const
Clone.
labelList sizes() const
The local row sizes. Same as localSizes.
T * data() noexcept
Return pointer to the first data in values()
CompactListList() noexcept=default
Default construct.
const T * cdata() const noexcept
Return const pointer to the first data in values()
void resize(const label mRows)
Reset size of CompactListList.
errorManip< error > abort(error &err)
const SubList< T > localList(const label i) const
Return const access to sub-list (no subscript checking)
const SubList< T > operator[](const label i) const
Return const access to sub-list (no subscript checking)
A packed storage of objects of type <T> using an offset table for access.
label totalSize() const noexcept
The total addressed size, which corresponds to the end (back) offset and also the sum of all localSiz...
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
label whichRow(const label i) const
Which row does global index come from? Binary search.
label maxSize() const
The max row length used.
label length() const noexcept
The primary size (the number of rows/sublists)
void operator=(const CompactListList< T > &list)
Copy assignment.
static const UList< label > & null() noexcept
Return a null UList (reference to a nullObject). Behaves like an empty UList.
const labelUList localStarts() const
The local row starts.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
void resize_nocopy(const label mRows, const label nVals)
Redimension without preserving existing content.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
bool single() const noexcept
True if content is a single row/sublist only. Such content could be flattened out into a straight lis...
friend Ostream & operator(Ostream &, const CompactListList< T > &)
Write CompactListList as offsets/values pair.