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
93 template<
class ListListType>
94 static CompactListList<T> packImpl
96 const ListListType& lists,
97 const bool checkOverflow =
false 101 void enforceSizeSanity();
104 label maxNonLocalSize(
const label rowi)
const;
136 template<
class SubListType = List<T>>
140 const bool checkOverflow =
false 144 template<
class SubListType,
class Addr>
148 const bool checkOverflow =
false 173 const label mRows, const label nVals, const
Foam::
zero 260 inline label
localEnd(const label i) const;
263 inline label
localSize(const label i) const;
282 inline
void resize(const label mRows);
285 inline
void resize(const label mRows, const label nVals);
288 inline
void resize_nocopy(const label mRows, const label nVals);
291 inline
void resize(const label mRows, const label nVals, const
T&);
301 inline
void setSize(const label mRows);
304 inline
void setSize(const label mRows, const label nVals);
307 inline
void setSize(const label mRows, const label nVals, const
T&);
323 inline label
toGlobal(const label rowi, const label i) const;
326 inline label
toLocal(const label rowi, const label i) const;
330 inline label
findRow(const label i) const;
334 inline label
whichRow(const label i) const;
340 template<class SubListType =
List<
T>>
344 template<class SubListType =
List<
T>>
381 inline
T&
operator()(const label i, const label j);
384 inline const
T&
operator()(const label i, const label j) const;
424 label
index(
const label rowi,
const label colj)
const 430 label
whichColumn(
const label rowi,
const label i)
const 442 Istream&
operator>>(Istream& is, CompactListList<T>& list)
444 return list.readList(is);
448 Ostream& operator<<(Ostream& os, const CompactListList<T>& list)
450 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.
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)
const labelList & offsets() const noexcept
Return the offset table (= size()+1)
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.
const List< T > & values() const noexcept
Return the packed matrix of values.
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.
label totalSize() const
The total addressed size.
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 &)
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.
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 unstructured matrix 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)
Database for solution data, solver performance and other reduced data.
static const UList< label > & null()
Return a UList reference to a nullObject.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Istream & readList(Istream &is)
Read CompactListList as offsets/values pair from Istream, discards current list contents.
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.
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.
List< label > labelList
A List of labels.
const List< T > & m() const noexcept
Const access to the packed matrix of values.