opm-grid
Loading...
Searching...
No Matches
Opm::SparseTable< T, Storage > Class Template Reference

A SparseTable stores a table with rows of varying size as efficiently as possible. More...

#include <SparseTable.hpp>

Classes

struct  row_type_helper
struct  row_type_helper< U, std::void_t< typename U::const_iterator > >
class  Iterator
 Iterator for iterating over the container as a whole, i.e. More...

Public Types

using row_type = typename row_type_helper<Storage<T>>::const_type
using mutable_row_type = typename row_type_helper<Storage<T>>::mutable_type

Public Member Functions

 SparseTable ()
 Default constructor. Yields an empty SparseTable.
template<typename DataIter, typename IntegerIter>
 SparseTable (DataIter data_beg, DataIter data_end, IntegerIter rowsize_beg, IntegerIter rowsize_end)
 A constructor taking all the data for the table and row sizes.
 SparseTable (Storage< T > &&data, Storage< int > &&row_starts)
template<typename DataIter, typename IntegerIter>
void assign (DataIter data_beg, DataIter data_end, IntegerIter rowsize_beg, IntegerIter rowsize_end)
 Sets the table to contain the given data, organized into rows as indicated by the given row sizes.
template<typename IntegerIter>
void allocate (IntegerIter rowsize_beg, IntegerIter rowsize_end)
 Request storage for table of given size.
template<typename DataIter>
void appendRow (DataIter row_beg, DataIter row_end)
 Appends a row to the table.
OPM_HOST_DEVICE bool empty () const
 True if the table contains no rows.
OPM_HOST_DEVICE int size () const
 Returns the number of rows in the table.
void reserve (int exptd_nrows, int exptd_ndata)
 Allocate storage for table of expected size.
void swap (SparseTable< T > &other)
 Swap contents for other SparseTable<T>.
OPM_HOST_DEVICE int dataSize () const
 Returns the number of data elements.
OPM_HOST_DEVICE int rowSize (int row) const
 Returns the size of a table row.
void clear ()
 Makes the table empty().
OPM_HOST_DEVICE row_type operator[] (int row) const
 Returns a row of the table.
OPM_HOST_DEVICE mutable_row_type operator[] (int row)
 Returns a mutable row of the table.
OPM_HOST_DEVICE Iterator begin () const
 Iterator access.
OPM_HOST_DEVICE Iterator end () const
OPM_HOST_DEVICE bool operator== (const SparseTable &other) const
 Equality.
template<class charT, class traits>
void print (std::basic_ostream< charT, traits > &os) const
const T data (int i) const
const T * dataPtr () const
const Storage< T > & dataStorage () const
const Storage< int > & rowStarts () const

Detailed Description

template<typename T, template< typename, typename... > class Storage = std::vector>
class Opm::SparseTable< T, Storage >

A SparseTable stores a table with rows of varying size as efficiently as possible.

It is supposed to behave similarly to a vector of vectors. Its behaviour is similar to compressed row sparse matrices.

Constructor & Destructor Documentation

◆ SparseTable()

template<typename T, template< typename, typename... > class Storage = std::vector>
template<typename DataIter, typename IntegerIter>
Opm::SparseTable< T, Storage >::SparseTable ( DataIter data_beg,
DataIter data_end,
IntegerIter rowsize_beg,
IntegerIter rowsize_end )
inline

A constructor taking all the data for the table and row sizes.

Parameters
data_begThe start of the table data.
data_endOne-beyond-end of the table data.
rowsize_begThe start of the row length data.
rowsize_endOne beyond the end of the row length data.

Member Function Documentation

◆ allocate()

template<typename T, template< typename, typename... > class Storage = std::vector>
template<typename IntegerIter>
void Opm::SparseTable< T, Storage >::allocate ( IntegerIter rowsize_beg,
IntegerIter rowsize_end )
inline

Request storage for table of given size.

Parameters
rowsize_begStart of row size data.
rowsize_endOne beyond end of row size data.

◆ assign()

template<typename T, template< typename, typename... > class Storage = std::vector>
template<typename DataIter, typename IntegerIter>
void Opm::SparseTable< T, Storage >::assign ( DataIter data_beg,
DataIter data_end,
IntegerIter rowsize_beg,
IntegerIter rowsize_end )
inline

Sets the table to contain the given data, organized into rows as indicated by the given row sizes.

Parameters
data_begThe start of the table data.
data_endOne-beyond-end of the table data.
rowsize_begThe start of the row length data.
rowsize_endOne beyond the end of the row length data.

The documentation for this class was generated from the following file: