typename Accessor<number,Constness>::MatrixType
MatrixType;
+ /**
+ * A typedef for the type you get when you dereference an iterator
+ * of the current kind.
+ */
+ typedef
+ const Accessor<number,Constness> & value_type;
+
/**
* Constructor. Create an iterator into the matrix @p matrix for the given
* row and the index within it.
*/
bool operator > (const Iterator &) const;
+ /**
+ * Return the distance between the current iterator and the argument.
+ * The distance is given by how many times one has to apply operator++
+ * to the current iterator to get the argument (for a positive return
+ * value), or operator-- (for a negative return value).
+ */
+ int operator - (const Iterator &p) const;
+
+ /**
+ * Return an iterator that is @p n ahead of the current one.
+ */
+ Iterator operator + (const unsigned int n) const;
+
private:
/**
* Store an object of the accessor class.
return (other < *this);
}
+
+ template <typename number, bool Constness>
+ inline
+ int
+ Iterator<number,Constness>::
+ operator - (const Iterator &other) const
+ {
+ Assert (&accessor.get_matrix() == &other.accessor.get_matrix(),
+ ExcInternalError());
+
+ if ((*this)->row() == other->row())
+ return ((*this)->index() - other->index());
+ else
+ {
+//TODO: this shouldn't be so hard to implement. it could either be done as
+// std::difference(*this, other), but for that we lack a bunch of typedefs
+// in the iterator class; it is also inefficient since it has linear complexity
+// in the distance. alternatively, one should be able to just add up the
+// entries in all of the rows of the matrix between *this and other
+ Assert (false, ExcNotImplemented());
+ return 0;
+ }
+ }
+
+
+ template <typename number, bool Constness>
+ inline
+ Iterator<number,Constness>
+ Iterator<number,Constness>::
+ operator + (const unsigned int n) const
+ {
+ Iterator x = *this;
+ for (unsigned int i=0; i<n; ++i)
+ ++x;
+
+ return x;
+ }
+
}