Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * const bidirectional iterator
- */
- class const_iterator : public std::iterator<std::bidirectional_iterator_tag, T>
- {
- private:
- typename std::vector<std::vector<T> >::const_iterator _rowIt, _rowsEnd;
- typename std::vector<T>::const_iterator _colIt;
- public:
- /**
- * @param rowIt points to a row
- * @param rowsEnd points to the end of the rows
- * @param colIt points to a cell within that row
- */
- const_iterator(typename std::vector<std::vector<T> >::const_iterator rowIt,
- typename std::vector<std::vector<T> >::const_iterator rowsEnd,
- typename std::vector<T>::const_iterator colIt)
- : _rowIt(rowIt), _rowsEnd(rowsEnd), _colIt(colIt) {}
- /**
- * default c-tor
- */
- const_iterator() {}
- /**
- * prefix
- * @return ref to the incremented iterator
- */
- const_iterator& operator++();
- /**
- * postfix
- * @return the non-incremented iterator
- */
- const_iterator operator++(int);
- /**
- * prefix
- * @return ref to the decremented iterator
- */
- const_iterator& operator--();
- /**
- * postfix
- * @return the non-decremented iterator
- */
- const_iterator operator--(int);
- /**
- * @return whether other is equal
- */
- bool operator==(const const_iterator& other) const
- {
- return _rowIt == other._rowIt && _colIt == other._colIt;
- }
- /**
- * @return whether other is not equal
- */
- bool operator!=(const const_iterator& other) const
- {
- return !(*this == other);
- }
- const T& operator*() const
- {
- return *_colIt;
- }
- T* operator->() const
- {
- return &(*_colIt);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement