37 return NullObjectRef<CompactListList<T>>();
46 if (offsets_.size() == 1)
65 offsets_(list.offsets_),
76 offsets_(
std::move(list.offsets_)),
77 values_(
std::move(list.values_))
88 offsets_(list.offsets_, reuse),
89 values_(list.values_, reuse)
101 offsets_(mRows+1,
Zero),
116 offsets_(mRows+1,
Zero),
131 offsets_(mRows+1,
Zero),
179 return values_.cdata();
186 return values_.data();
193 return values_.cdata_bytes();
200 return values_.data_bytes();
207 return values_.size_bytes();
214 return (offsets_.size() <= 1);
221 const label len = (offsets_.size() - 1);
222 return (len < 1) ?
static_cast<label
>(0) : len;
236 const label len = (offsets_.size() - 1);
237 return (len < 1) ?
static_cast<label
>(0) : offsets_[len];
244 return this->maxNonLocalSize(-1);
252 const label len = (offsets_.size() - 1);
254 if (len < 1)
return labelUList::null();
270 return offsets_[i+1];
277 return offsets_[i+1] - offsets_[i];
285 return SubList<T>(values_, (offsets_[i+1] - offsets_[i]), offsets_[i]);
293 return SubList<T>(values_, (offsets_[i+1] - offsets_[i]), offsets_[i]);
304 return i + offsets_[rowi];
315 const label locali = i - offsets_[rowi];
317 if (locali < 0 || i >= offsets_[rowi+1])
320 <<
"Index " << i <<
" does not belong on row " 321 << rowi <<
nl <<
"Offsets:" << offsets_
332 return (i < 0 || i >= totalSize()) ? -1 :
findLower(offsets_, i+1);
339 const label rowi = findRow(i);
344 <<
"Index " << i <<
" outside of range" <<
nl 345 <<
"Offsets:" << offsets_
370 else if (mRows < size())
373 offsets_.resize(mRows+1);
374 values_.resize(offsets_[mRows]);
376 else if (mRows > size())
380 <<
"Cannot be used to extend the list from " << size()
381 <<
" to " << mRows <<
nl 382 <<
" Please use a different resize() function" 395 offsets_.resize(mRows+1,
Zero);
396 values_.resize(nVals);
407 offsets_.resize(mRows+1,
Zero);
408 values_.resize_nocopy(nVals);
420 offsets_.resize(mRows+1,
Zero);
421 values_.resize(nVals, val);
440 this->
resize(mRows+1, nVals);
452 this->
resize(mRows+1, nVals, val);
479 offsets_ = list.offsets_,
480 values_ = list.values_;
496 values_.transfer(list.values_);
518 return this->localList(i);
526 return this->localList(i);
537 return values_[toGlobal(i, j)];
548 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)
patchWriters resize(patchIds.size())
const labelList & offsets() const noexcept
Return the offset table (= size()+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.
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.
UList< T > localList(const label i)
Return non-const access to sub-list (no subscript checking)
char * data_bytes() noexcept
Return pointer to underlying values storage, reinterpreted as byte data.
const List< T > & values() const noexcept
Return the packed matrix of values.
void clear()
Clear addressing and contents.
static const CompactListList< T > & null()
Return a CompactListList reference to a nullObject.
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.
label totalSize() const
The total addressed size.
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.
UList< T > operator[](const label i)
Return row as UList - same as localList method.
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)
A packed storage unstructured matrix of objects of type <T> using an offset table for access...
void setSize(const label mRows)
Redimension - same as resize()
label whichRow(const label i) const
Which row does global index come from? Binary search.
label maxSize() const
The max row length used.
void operator=(const CompactListList< T > &list)
Copy assignment.
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...
friend Ostream & operator(Ostream &, const CompactListList< T > &)
Write CompactListList as offsets/values pair.
static constexpr const zero Zero
Global zero (0)