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),
151 return values_.cdata();
158 return values_.data();
165 return values_.cdata_bytes();
172 return values_.data_bytes();
179 return values_.size_bytes();
189 return (offsets_.size() <= 1);
196 return (offsets_.size() == 2);
203 const label len = (offsets_.size() - 1);
204 return (len < 1) ?
static_cast<label
>(0) : len;
211 const label len = (offsets_.size() - 1);
212 return (len < 1) ?
static_cast<label
>(0) : len;
226 return offsets_.empty() ? 0 : *(offsets_.cdata() + offsets_.size()-1);
233 return this->maxNonLocalSize(-1);
241 const label len = (offsets_.size() - 1);
243 if (len < 1)
return labelUList::null();
259 return offsets_[i+1];
266 return offsets_[i+1] - offsets_[i];
274 return SubList<T>(values_, (offsets_[i+1] - offsets_[i]), offsets_[i]);
282 return SubList<T>(values_, (offsets_[i+1] - offsets_[i]), offsets_[i]);
293 return i + offsets_[rowi];
304 const label locali = i - offsets_[rowi];
306 if (locali < 0 || i >= offsets_[rowi+1])
309 <<
"Index " << i <<
" does not belong on row " 310 << rowi <<
nl <<
"Offsets:" << offsets_
321 return (i < 0 || i >= totalSize()) ? -1 :
findLower(offsets_, i+1);
328 const label rowi = findRow(i);
333 <<
"Index " << i <<
" outside of range" <<
nl 334 <<
"Offsets:" << offsets_
359 else if (mRows < size())
362 offsets_.resize(mRows+1);
363 values_.resize(offsets_[mRows]);
365 else if (mRows > size())
368 const label endOffset = offsets_.empty() ? 0 : offsets_.back();
370 offsets_.resize(mRows+1, endOffset);
390 offsets_.resize(mRows+1,
Zero);
391 values_.resize(nVals);
411 offsets_.resize(mRows+1,
Zero);
412 values_.resize_nocopy(nVals);
433 offsets_.resize(mRows+1,
Zero);
434 values_.resize(nVals, val);
452 offsets_ = list.offsets_,
453 values_ = list.values_;
469 values_.transfer(list.values_);
491 return this->localList(i);
499 return this->localList(i);
510 return values_[toGlobal(i, j)];
521 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.
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.
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.
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 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...
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.
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.
static constexpr const zero Zero
Global zero (0)