1 #ifndef CYCLIC_ITERATOR_H_ 2 #define CYCLIC_ITERATOR_H_ 10 template <
typename TContainer,
typename TIterator >
13 if (++i == c.end()) i = c.begin();
35 template <
typename TIterator >
47 template <
typename TContainer >
50 template <
typename TContainer >
51 cyclic_iterator_base(TContainer &c,
const TIterator & i) : m_iterator(i), m_begin(c.begin()), m_end(c.end())
56 if (m_iterator == m_end) m_iterator = m_begin;
63 typename std::iterator_traits<TIterator>::reference
66 const typename std::iterator_traits<TIterator>::reference
72 if (m_iterator == m_end) m_iterator = m_begin;
77 if (m_iterator == m_begin) m_iterator = m_end;
86 return m_iterator != i;
110 template <
typename TContainer >
126 template <
typename TContainer >
135 cyclic_iterator(TContainer & c,
const typename TContainer::iterator & i) : Base(c, i) {}
const_cyclic_iterator(const TContainer &c)
bool operator!=(const TIterator &i)
cyclic_iterator_base(TContainer &c, const TIterator &i)
NB: it is assumed that i does point on one of the element of c (end() accepted)
Belongs to package Box Do not include directly, include til/Box.h instead.
A const cyclic iterator is a const iterator that goes back to the begining of the container when it r...
std::iterator_traits< TIterator >::reference operator*()
cyclic_iterator(TContainer &c, const typename TContainer::iterator &i)
cyclic_iterator_base(TContainer &c)
TIterator cyclic_advance(TIterator i, TContainer &c)
detail::cyclic_iterator_base< typename TContainer::const_iterator > Base
A cyclic iterator is an iterator that goes back to the begining of the container when it reaches the ...
const_cyclic_iterator(const TContainer &c, const typename TContainer::const_iterator &i)
cyclic_iterator(TContainer &c)
const std::iterator_traits< TIterator >::reference operator*() const
detail::cyclic_iterator_base< typename TContainer::iterator > Base
TODO: when implementing the operator+=, it might be that we need to split the class in different part...