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>&);
91 static void reportOverflowAndExit
94 const label prevOffset = -1,
99 template<
class ListListType>
102 const ListListType& lists,
103 const bool checkOverflow =
false 107 inline void enforceSizeSanity();
110 label maxNonLocalSize(
const label rowi)
const;
118 const bool checkOverflow =
false 149 return NullObjectRef<CompactListList<T>>();
153 template<
class SubListType = List<T>>
157 const bool checkOverflow =
false 161 template<
class SubListType,
class Addr>
165 const bool checkOverflow =
false 190 const label mRows, const label nVals, const
Foam::
zero 286 inline label
localEnd(const label i) const;
289 inline label
localSize(const label i) const;
292 List<labelRange>
ranges() const;
308 inline
void resize(const label mRows);
311 inline
void resize(const label mRows, const label nVals);
314 inline
void resize_nocopy(const label mRows, const label nVals);
317 inline
void resize(const label mRows, const label nVals, const
T&);
341 inline label
toGlobal(const label rowi, const label i) const;
344 inline label
toLocal(const label rowi, const label i) const;
348 inline label
findRow(const label i) const;
352 inline label
whichRow(const label i) const;
363 template<class SubListType, class OutputIter>
378 template<class SubListType, class OutputIter>
391 template<class SubListType, class OutputIter>
401 template<class SubListType =
List<
T>>
405 template<class SubListType =
List<
T>>
409 template<class SubListType =
List<
T>>
446 inline
T&
operator()(const label i, const label j);
449 inline const
T&
operator()(const label i, const label j) const;
497 label
index(
const label rowi,
const label colj)
const 503 label
whichColumn(
const label rowi,
const label i)
const 509 void setSize(
const label mRows)
515 void setSize(
const label mRows,
const label nVals)
517 this->
resize(mRows, nVals);
521 void setSize(
const label mRows,
const label nVals,
const T& val)
523 this->
resize(mRows, nVals, val);
537 Istream&
operator>>(Istream& is, CompactListList<T>& list)
539 return list.readList(is);
543 Ostream& operator<<(Ostream& os, const CompactListList<T>& list)
545 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)
CompactListList< label > labelCompactListList
A CompactListList of labels.
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.
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.
static const CompactListList< T > & null() noexcept
Return a null CompactListList (reference to a nullObject).
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.
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.
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.
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)
const SubList< T > localList(const label i) const
Return const access to sub-list (no subscript checking)
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.