2 #ifndef MATH_ITERATOR_H
3 #define MATH_ITERATOR_H
10 // this is used for traversing math insets
12 class MathIterator : private std::vector<CursorPos> {
14 // re-use inherited stuff
15 typedef std::vector<CursorPos> base_type;
16 using base_type::clear;
17 using base_type::size;
18 using base_type::push_back;
19 using base_type::pop_back;
20 using base_type::back;
21 using base_type::begin;
23 using base_type::erase;
24 using base_type::operator[];
25 using base_type::size_type;
26 using base_type::difference_type;
27 using base_type::const_iterator;
28 friend bool operator!=(MathIterator const &, MathIterator const &);
29 friend bool operator==(MathIterator const &, MathIterator const &);
31 /// default constructor
33 /// start with given inset
34 explicit MathIterator(MathInset * p);
36 CursorPos const & operator*() const;
38 CursorPos const & operator->() const;
41 /// move on several steps
42 void jump(difference_type);
43 /// read access to top most inset
44 MathInset const * inset() const;
45 /// read access to top most inset
49 /// read access to top most item
50 MathArray const & cell() const;
51 /// is this a non-end position
53 /// shrinks to at most i levels
54 void shrink(size_type i);
58 void push(MathInset *);
64 bool operator==(MathIterator const &, MathIterator const &);
66 bool operator!=(MathIterator const &, MathIterator const &);
69 MathIterator ibegin(MathInset * p);
71 MathIterator iend(MathInset * p);