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);
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)];
Various functions to operate on Lists.
A packed storage unstructured matrix of objects of type <T> using an offset table for access.
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
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.
void transfer(CompactListList< T > &list)
Transfer contents into this and annul the argument.
friend Ostream & operator(Ostream &, const CompactListList< T > &)
Write CompactListList as offsets/values pair.
static const CompactListList< T > & null()
Return a CompactListList reference to a nullObject.
label size() const noexcept
The primary size (the number of rows/sublists)
void operator=(const CompactListList< T > &list)
Copy assignment.
label totalSize() const
The total addressed size.
T * data() noexcept
Return pointer to the first data in values()
labelList sizes() const
The local row sizes. Same as localSizes.
const char * cdata_bytes() const noexcept
label localEnd(const label i) const
End offset (exclusive) for given row.
const List< T > & values() const noexcept
Return the packed matrix of values.
void clear()
Clear addressing and contents.
std::streamsize size_bytes() const noexcept
label toLocal(const label rowi, const label i) const
From global to local index on rowi.
const labelList & offsets() const noexcept
Return the offset table (= size()+1)
UList< T > localList(const label i)
Return non-const access to sub-list (no subscript checking)
CompactListList() noexcept=default
Default construct.
void setSize(const label mRows)
Redimension - same as resize()
UList< T > operator[](const label i)
Return row as UList - same as localList method.
autoPtr< CompactListList< T > > clone() const
Clone.
label toGlobal(const label rowi, const label i) const
virtual bool resize()
Resize the ODE solver.
SubList< label > subList
Declare type of subList.
A List obtained as a section of another List.
static const UList< label > & null()
Return a UList reference to a nullObject.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
label localSize() const
My local size.
label localStart() const
My local start.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
patchWriters resize(patchIds.size())
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
constexpr char nl
The newline '\n' character (0x0a)