A SparseVector stores a vector with possibly many empty elements as efficiently as possible.
More...
#include <SparseVector.hpp>
template<typename T>
class Opm::SparseVector< T >
A SparseVector stores a vector with possibly many empty elements as efficiently as possible.
It is supposed to behave similarly to a standard vector, but since direct indexing is a O(log n) operation instead of O(1), we do not supply it as operator[].
◆ SparseVector()
template<typename T >
template<typename DataIter , typename IntegerIter >
A constructor taking all the element data for the vector and their indices.
- Parameters
-
data_beg | The start of the element data. |
data_end | One-beyond-end of the element data. |
rowsize_beg | The start of the index data. |
rowsize_end | One beyond the end of the index data. |
◆ addElement()
Appends an element to the vector.
Note that this function does not increase the size() of the vector, it just adds another nonzero element. Elements must be added in index order.
◆ element()
O(log n) element access.
- Parameters
-
index | the proper vector index |
- Returns
- the element with the given index, or the default element if no element in the vector has the given index.
◆ empty()
- Returns
- true if the vector has size 0.
◆ nonzeroElement()
O(1) element access.
- Parameters
-
nzindex | an index counting only nonzero elements. |
- Returns
- the nzindex'th nonzero element.
◆ nonzeroIndex()
O(1) index access.
- Parameters
-
nzindex | an index counting only nonzero elements. |
- Returns
- the index of the nzindex'th nonzero element.
◆ size()
Returns the size of the vector.
Recall that most or all of the vector may be default/zero.
The documentation for this class was generated from the following file: