50 #ifndef Foam_CompactListList_H 51 #define Foam_CompactListList_H 61 template<
class T>
class CompactListList;
63 template<
class T> Istream&
operator>>(Istream&, CompactListList<T>&);
64 template<
class T> Ostream& operator<<(Ostream&, const CompactListList<T>&);
86 static void reportOverflowAndExit
89 const label prevOffset = -1,
94 template<
class ListListType>
95 static CompactListList<T> pack_impl
97 const ListListType& lists,
98 const bool checkOverflow =
false 102 inline void enforceSizeSanity();
105 label maxNonLocalSize(
const label rowi)
const;
113 const bool checkOverflow =
false 145 template<
class SubListType = List<T>>
149 const bool checkOverflow =
false 153 template<
class SubListType,
class Addr>
157 const bool checkOverflow =
false 182 const label mRows, const label nVals, const
Foam::
zero 278 inline label
localEnd(const label i) const;
281 inline label
localSize(const label i) const;
284 List<labelRange>
ranges() const;
300 inline
void resize(const label mRows);
303 inline
void resize(const label mRows, const label nVals);
306 inline
void resize_nocopy(const label mRows, const label nVals);
309 inline
void resize(const label mRows, const label nVals, const
T&);
333 inline label
toGlobal(const label rowi, const label i) const;
336 inline label
toLocal(const label rowi, const label i) const;
340 inline label
findRow(const label i) const;
344 inline label
whichRow(const label i) const;
355 template<class SubListType, class OutputIter>
370 template<class SubListType, class OutputIter>
383 template<class SubListType, class OutputIter>
393 template<class SubListType =
List<
T>>
397 template<class SubListType =
List<
T>>
401 template<class SubListType =
List<
T>>
438 inline
T&
operator()(const label i, const label j);
441 inline const
T&
operator()(const label i, const label j) const;
489 label
index(
const label rowi,
const label colj)
const 495 label
whichColumn(
const label rowi,
const label i)
const 501 void setSize(
const label mRows)
507 void setSize(
const label mRows,
const label nVals)
509 this->
resize(mRows, nVals);
513 void setSize(
const label mRows,
const label nVals,
const T& val)
515 this->
resize(mRows, nVals, val);
529 Istream&
operator>>(Istream& is, CompactListList<T>& list)
531 return list.readList(is);
535 Ostream& operator<<(Ostream& os, const CompactListList<T>& list)
537 return list.writeList(
os, Detail::ListPolicy::short_length<T>::value);
label index(const label rowi, const label colj) const
Return flat index into packed values.
label localStart(const label i) const
Starting offset for given row.
const T & const_reference
The type used for reading from constant value_type objects.
T * pointer
The pointer type for non-const access to value_type items.
T & reference
The type used for storing into value_type objects.
const labelList & offsets() const noexcept
Return the offset table (= size()+1)
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.
label whichColumn(const label rowi, const label i) const
Get column within specified row that corresponds to global index.
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)
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write CompactListList as offsets/values pair.
label toGlobal(const label rowi, const label i) const
From local index on rowi to global (flat) indexing into packed values.
A range or interval of labels defined by a start and a size.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
void swap(CompactListList< T > &other)
Swap contents.
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.
static CompactListList< T > pack(const UList< SubListType > &lists, const bool checkOverflow=false)
Construct by packing together the list of lists.
void clear()
Clear addressing and contents.
Base for lists with indirect addressing, templated on the list contents type and the addressing type...
UList< label > labelUList
A UList of labels.
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.
const char * cdata_bytes() const noexcept
Return const pointer to underlying values storage, reinterpreted as byte data.
void setLocalSize(const label rowi, const label len)
Alter local addressing size for given row, does not change content.
label findRow(const label i) const
Find row where global index comes from. Binary search.
List< labelRange > ranges() const
Return start/size ranges for all sub-lists.
dimensionedScalar pos(const dimensionedScalar &ds)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
label localEnd(const label i) const
End offset (exclusive) for given row.
autoPtr< CompactListList< T > > clone() const
Clone.
const T * const_pointer
The pointer type for const access to value_type items.
List< SubListType > unpack() const
Return non-compact list of lists.
labelRange range(const label i) const
Return start/size range for given sub-list.
labelList sizes() const
The local row sizes. Same as localSizes.
Istream & operator>>(Istream &, directionInfo &)
T * data() noexcept
Return pointer to the first data in values()
CompactListList() noexcept=default
Default construct.
label size_type
The type to represent the size of a CompactListList.
const T * cdata() const noexcept
Return const pointer to the first data in values()
void resize(const label mRows)
Reset size of CompactListList.
#define FOAM_DEPRECATED_STRICT(since, replacement)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
std::streamsize byteSize() const
Number of contiguous bytes for the values data, runtime FatalError if type is not contiguous...
A packed storage of objects of type <T> using an offset table for access.
void setSize(const label mRows)
Redimension - same as resize()
An Ostream is an abstract base class for all output systems (streams, files, token lists...
T value_type
The value type the list contains.
OBJstream os(runTime.globalPath()/outputName)
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)
Ostream & writeMatrix(Ostream &os, const label shortLen=0) const
Write CompactListList as a formatted matrix of values (ASCII)
Istream & readList(Istream &is)
Read CompactListList as offsets/values pair from Istream, discards current list contents.
OutputIter copy_unpack(OutputIter d_iter, const label pos=0, label len=-1) const
Unpack sub-list copies in the range defined by pos and len with bounding behaviour like List::slice()...
labelList localSizes() const
The local row sizes.
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)
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 ...
const List< T > & values() const noexcept
Return the packed values.
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.
List< label > labelList
A List of labels.
const List< T > & m() const noexcept
Const access to the packed values.