class cv::SparseMatConstIterator

Overview

Read-Only Sparse Matrix Iterator. Moreā€¦

#include <mat.hpp>

class SparseMatConstIterator
{
public:
    // fields

    size_t hashidx;
    const SparseMat* m;
    uchar* ptr;

    // construction

    SparseMatConstIterator();
    SparseMatConstIterator(const SparseMat* _m);
    SparseMatConstIterator(const SparseMatConstIterator& it);

    // methods

    const SparseMat::Node*
    node() const;

    SparseMatConstIterator&
    operator++();

    SparseMatConstIterator
    operator++(int);

    SparseMatConstIterator&
    operator--();

    SparseMatConstIterator
    operator--(int);

    SparseMatConstIterator&
    operator=(const SparseMatConstIterator& it);

    void
    seekEnd();

    template <typename _Tp>
    const _Tp&
    value() const;
};

// direct descendants

template <typename _Tp>
class SparseMatConstIterator_;

class SparseMatIterator;

Detailed Documentation

Read-Only Sparse Matrix Iterator.

Here is how to use the iterator to compute the sum of floating-point sparse matrix elements:

SparseMatConstIterator it = m.begin(), it_end = m.end();
double s = 0;
CV_Assert( m.type() == CV_32F );
for( ; it != it_end; ++it )
   s += it.value<float>();

Construction

SparseMatConstIterator()

the default constructor

SparseMatConstIterator(const SparseMat* _m)

the full constructor setting the iterator to the first sparse matrix element

SparseMatConstIterator(const SparseMatConstIterator& it)

the copy constructor

Methods

const SparseMat::Node*
node() const

returns the current node of the sparse matrix. it.node->idx is the current element index

SparseMatConstIterator&
operator++()

moves iterator to the next element

SparseMatConstIterator
operator++(int)

moves iterator to the next element

SparseMatConstIterator&
operator--()

moves iterator to the previous element

SparseMatConstIterator
operator--(int)

moves iterator to the previous element

SparseMatConstIterator&
operator=(const SparseMatConstIterator& it)

the assignment operator

void
seekEnd()

moves iterator to the element after the last element

template <typename _Tp>
const _Tp&
value() const

template method returning the current matrix element