Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. /**
  2. * const bidirectional iterator
  3. */
  4. class const_iterator : public std::iterator<std::bidirectional_iterator_tag, T>
  5. {
  6. private:
  7. typename std::vector<std::vector<T> >::const_iterator _rowIt, _rowsEnd;
  8. typename std::vector<T>::const_iterator _colIt;
  9. public:
  10. /**
  11. * @param rowIt points to a row
  12. * @param rowsEnd points to the end of the rows
  13. * @param colIt points to a cell within that row
  14. */
  15. const_iterator(typename std::vector<std::vector<T> >::const_iterator rowIt,
  16. typename std::vector<std::vector<T> >::const_iterator rowsEnd,
  17. typename std::vector<T>::const_iterator colIt)
  18. : _rowIt(rowIt), _rowsEnd(rowsEnd), _colIt(colIt) {}
  19.  
  20. /**
  21. * default c-tor
  22. */
  23. const_iterator() {}
  24.  
  25. /**
  26. * prefix
  27. * @return ref to the incremented iterator
  28. */
  29. const_iterator& operator++();
  30. /**
  31. * postfix
  32. * @return the non-incremented iterator
  33. */
  34. const_iterator operator++(int);
  35. /**
  36. * prefix
  37. * @return ref to the decremented iterator
  38. */
  39. const_iterator& operator--();
  40. /**
  41. * postfix
  42. * @return the non-decremented iterator
  43. */
  44. const_iterator operator--(int);
  45.  
  46. /**
  47. * @return whether other is equal
  48. */
  49. bool operator==(const const_iterator& other) const
  50. {
  51. return _rowIt == other._rowIt && _colIt == other._colIt;
  52. }
  53.  
  54. /**
  55. * @return whether other is not equal
  56. */
  57. bool operator!=(const const_iterator& other) const
  58. {
  59. return !(*this == other);
  60. }
  61.  
  62. const T& operator*() const
  63. {
  64. return *_colIt;
  65. }
  66.  
  67. T* operator->() const
  68. {
  69. return &(*_colIt);
  70. }
  71. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement