File iterator_forward_sparse.hpp

Functions

template<typename IndexIterator, typename ValueIterator>
static inline SparseForwardIterator<IndexIterator, ValueIterator> createSparseForwardIterator(IndexIterator indicesBegin, IndexIterator indicesEnd, ValueIterator valuesBegin, ValueIterator valuesEnd, uint32 startIndex = 0, typename util::iterator_value<ValueIterator> sparseValue = 0)

Creates and returns a new SparseForwardIterator.

Template Parameters:
  • IndexIterator – The type of the iterator that provides access to the indices of all dense elements explicitly stored in the vector

  • ValueIterator – The type of the iterator that provides access to the values of all dense elements explicitly stored in the vector

Parameters:
  • indicesBegin – An iterator to the beginning of the indices of all dense elements explicitly stored in the vector

  • indicesEnd – An iterator to the end of the indices of all dense elements explicitly stored in the vector

  • valuesBegin – An iterator to the beginning of the values of all dense elements explicitly stored in the vector

  • valuesEnd – An iterator to the end of the values of all dense elements explicitly stored in the vector

  • startIndex – The index to start at

  • sparseValue – The value to be used for sparse elements not explicitly stored in the vector

Returns:

A SparseForwardIterator that has been created

template<typename IndexIterator, typename ValueIterator>
class SparseForwardIterator
#include <iterator_forward_sparse.hpp>

An iterator adaptor that adapts iterators of a sparse vector, which provide access to a fixed number of indices in increasing order, as well as corresponding values, such that it acts as a forward iterator that returns a value for each possible index, using sparse values for elements not explicitly stored in the vector.

Template Parameters:
  • IndexIterator – The type of the iterator that provides access to the indices of all dense elements explicitly stored in the vector

  • ValueIterator – The type of the iterator that provides access to the values of all dense elements explicitly stored in the vector

Public Types

using difference_type = int

The type that is used to represent the difference between two iterators.

using value_type = util::iterator_value<ValueIterator>

The type of the elements, the iterator provides access to.

using pointer = const value_type*

The type of a pointer to an element, the iterator provides access to.

using reference = value_type&

The type of a reference to an element, the iterator provides access to.

using iterator_category = std::forward_iterator_tag

The tag that specifies the capabilities of the iterator.

Public Functions

inline SparseForwardIterator(IndexIterator indicesBegin, IndexIterator indicesEnd, ValueIterator valuesBegin, ValueIterator valuesEnd, uint32 startIndex, typename util::iterator_value<ValueIterator> sparseValue)
Parameters:
  • indicesBegin – An iterator to the beginning of the indices of all dense elements explicitly stored in the vector

  • indicesEnd – An iterator to the end of the indices of all dense elements explicitly stored in the vector

  • valuesBegin – An iterator to the beginning of the values of all dense elements explicitly stored in the vector

  • valuesEnd – An iterator to the end of the values of all dense elements explicitly stored in the vector

  • startIndex – The index to start at

  • sparseValue – The value to be used for sparse elements not explicitly stored in the vector

inline value_type operator*() const

Returns the element, the iterator currently refers to.

Returns:

The element, the iterator currently refers to

inline SparseForwardIterator<IndexIterator, ValueIterator> &operator++()

Returns an iterator to the next element.

Returns:

A reference to an iterator that refers to the next element

inline SparseForwardIterator<IndexIterator, ValueIterator> &operator++(int n)

Returns an iterator to the next element.

Returns:

A reference to an iterator that refers to the next element

inline bool operator!=(const SparseForwardIterator<IndexIterator, ValueIterator> &rhs) const

Returns whether this iterator and another one refer to the same element.

Parameters:

rhs – A reference to another iterator

Returns:

True, if the iterators do not refer to the same element, false otherwise

inline bool operator==(const SparseForwardIterator<IndexIterator, ValueIterator> &rhs) const

Returns whether this iterator and another one refer to the same element.

Parameters:

rhs – A reference to another iterator

Returns:

True, if the iterators refer to the same element, false otherwise

Private Members

IndexIterator indexIterator_
IndexIterator indicesEnd_
ValueIterator valueIterator_
ValueIterator valuesEnd_
uint32 index_
uint32 iteratorIndex_
util::iterator_value<ValueIterator> sparseValue_