31#ifndef ETL_CIRCULAR_ITERATOR_INCLUDED
32#define ETL_CIRCULAR_ITERATOR_INCLUDED
36#include "static_assert.h"
42 namespace private_circular_iterator
47 template <
typename TIterator>
49 :
public etl::iterator<typename etl::iterator_traits<TIterator>::iterator_category, typename etl::iterator_traits<TIterator>::value_type>
53 typedef typename etl::iterator_traits<TIterator>::value_type value_type;
54 typedef typename etl::iterator_traits<TIterator>::difference_type difference_type;
55 typedef typename etl::iterator_traits<TIterator>::pointer pointer;
56 typedef typename etl::iterator_traits<TIterator>::reference reference;
57 typedef typename etl::iterator_traits<TIterator>::iterator_category iterator_category;
104 ETL_CONSTEXPR14 TIterator
begin()
const
112 ETL_CONSTEXPR14 TIterator
end()
const
120 ETL_CONSTEXPR14
size_t size()
const
168 ETL_CONSTEXPR14
operator TIterator()
const
193 template <typename TIterator, typename TTag = typename etl::iterator_traits<TIterator>::iterator_category>
205 template <
typename TIterator>
215 using common_t::operator=;
217 typedef typename common_t::value_type value_type;
218 typedef typename common_t::difference_type difference_type;
219 typedef typename common_t::pointer pointer;
220 typedef typename common_t::reference reference;
221 typedef typename common_t::iterator_category iterator_category;
235 : common_t(itr_begin_, itr_end_, itr_begin_)
243 : common_t(itr_begin_, itr_end_, start_)
296 template <
typename TIterator>
306 using common_t::operator=;
308 typedef typename common_t::value_type value_type;
309 typedef typename common_t::difference_type difference_type;
310 typedef typename common_t::pointer pointer;
311 typedef typename common_t::reference reference;
312 typedef typename common_t::iterator_category iterator_category;
326 : common_t(itr_begin_, itr_end_, itr_begin_)
334 : common_t(itr_begin_, itr_end_, start_)
390 this->
itr = ritr.base();
418 template <
typename TIterator>
428 using common_t::operator=;
430 typedef typename common_t::value_type value_type;
431 typedef typename common_t::difference_type difference_type;
432 typedef typename common_t::pointer pointer;
433 typedef typename common_t::reference reference;
434 typedef typename common_t::iterator_category iterator_category;
448 : common_t(itr_begin_, itr_end_, itr_begin_)
456 : common_t(itr_begin_, itr_end_, start_)
512 this->
itr = ritr.base();
539 const difference_type length = difference_type(this->
size());
544 const difference_type distance_from_begin = etl::distance(this->
itr_begin, this->
itr);
545 const difference_type distance_to_end = etl::distance(this->
itr, this->
itr_end);
549 if (distance_to_end > offset)
551 offset = distance_from_begin + offset;
555 offset = offset - distance_to_end;
562 if (distance_from_begin >= offset)
564 offset = distance_from_begin - offset;
568 offset = offset - distance_from_begin;
569 offset = length - offset;
584 return operator +=(-offset);
594 template <
typename TIterator>
604 using impl_t::operator=;
606 typedef typename impl_t::value_type value_type;
607 typedef typename impl_t::difference_type difference_type;
608 typedef typename impl_t::pointer pointer;
609 typedef typename impl_t::reference reference;
610 typedef typename impl_t::iterator_category iterator_category;
624 : impl_t(itr_begin_, itr_end_, itr_begin_)
632 : impl_t(itr_begin_, itr_end_, start_)
649 impl_t::operator=(other);
658 template <
typename TIterator>
659 ETL_CONSTEXPR14 etl::circular_iterator<TIterator>
operator +(etl::circular_iterator<TIterator>& lhs,
660 typename etl::iterator_traits<TIterator>::difference_type offset)
662 etl::circular_iterator<TIterator> result(lhs);
671 template <
typename TIterator>
672 ETL_CONSTEXPR14 etl::circular_iterator<TIterator>
operator -(etl::circular_iterator<TIterator>& lhs,
673 typename etl::iterator_traits<TIterator>::difference_type offset)
675 etl::circular_iterator<TIterator> result(lhs);
684 template <
typename TIterator>
685 ETL_CONSTEXPR14
typename etl::iterator_traits<TIterator>::difference_type
operator -(etl::circular_iterator<TIterator>& lhs,
686 etl::circular_iterator<TIterator>& rhs)
688 return TIterator(lhs) - TIterator(rhs);
694 template <
typename TIterator>
695 ETL_CONSTEXPR14
bool operator ==(
const etl::circular_iterator<TIterator>& lhs,
696 const etl::circular_iterator<TIterator>& rhs)
698 return TIterator(lhs) == TIterator(rhs);
704 template <
typename TIterator>
705 ETL_CONSTEXPR14
bool operator ==(
const etl::circular_iterator<TIterator>& lhs,
708 return TIterator(lhs) == rhs;
714 template <
typename TIterator>
716 const etl::circular_iterator<TIterator>& rhs)
718 return lhs == TIterator(rhs);
725 template <
typename TIterator>
726 ETL_CONSTEXPR14
bool operator !=(
const etl::circular_iterator<TIterator>& lhs,
727 const etl::circular_iterator<TIterator>& rhs)
729 return !(lhs == rhs);
735 template <
typename TIterator>
736 ETL_CONSTEXPR14
bool operator !=(
const etl::circular_iterator<TIterator>& lhs,
739 return !(lhs == rhs);
745 template <
typename TIterator>
747 const etl::circular_iterator<TIterator>& rhs)
749 return !(lhs == rhs);
Common circular iterator implementation.
Definition circular_iterator.h:50
ETL_CONSTEXPR14 TIterator current() const
Conversion to base iterator type.
Definition circular_iterator.h:176
ETL_CONSTEXPR14 value_type operator*()
Dereference operator.
Definition circular_iterator.h:136
TIterator itr_end
The underlying end iterator.
Definition circular_iterator.h:184
ETL_CONSTEXPR14 bool empty() const
Is there nothing to iterate over?
Definition circular_iterator.h:128
ETL_CONSTEXPR14 TIterator operator->()
-> operator.
Definition circular_iterator.h:152
ETL_CONSTEXPR14 circular_iterator_common(const circular_iterator_common &other)
Copy constructor.
Definition circular_iterator.h:82
ETL_CONSTEXPR14 circular_iterator_common()
Default constructor.
Definition circular_iterator.h:62
ETL_CONSTEXPR14 TIterator begin() const
Beginning of the range.
Definition circular_iterator.h:104
ETL_CONSTEXPR14 circular_iterator_common(TIterator itr_begin_, TIterator itr_end_, TIterator start_)
Construct from iterators.
Definition circular_iterator.h:72
TIterator itr_begin
The underlying begin iterator.
Definition circular_iterator.h:183
ETL_CONSTEXPR14 TIterator end() const
End of the range.
Definition circular_iterator.h:112
ETL_CONSTEXPR14 size_t size() const
How long is the range?
Definition circular_iterator.h:120
TIterator itr
The underlying iterator.
Definition circular_iterator.h:185
ETL_CONSTEXPR14 circular_iterator_common & operator=(const circular_iterator_common &other)
Assignment.
Definition circular_iterator.h:92
Definition iterator.h:228
ETL_CONSTEXPR14 circular_iterator_impl(const circular_iterator_impl &other)
Copy constructor.
Definition circular_iterator.h:463
ETL_CONSTEXPR14 circular_iterator()
Default constructor.
Definition circular_iterator.h:615
ETL_CONSTEXPR14 circular_iterator_impl(TIterator itr_begin_, TIterator itr_end_, TIterator start_)
Construct from start + iterators.
Definition circular_iterator.h:333
ETL_CONSTEXPR14 circular_iterator_impl(const circular_iterator_impl &other)
Copy constructor.
Definition circular_iterator.h:341
ETL_CONSTEXPR14 circular_iterator_impl(TIterator itr_begin_, TIterator itr_end_, TIterator start_)
Construct from start + iterators.
Definition circular_iterator.h:242
ETL_CONSTEXPR14 circular_iterator(const circular_iterator &other)
Copy constructor.
Definition circular_iterator.h:639
ETL_CONSTEXPR14 circular_iterator_impl(TIterator itr_begin_, TIterator itr_end_, TIterator start_)
Construct from start + iterators.
Definition circular_iterator.h:455
ETL_CONSTEXPR14 circular_iterator(TIterator itr_begin_, TIterator itr_end_)
Construct from iterators.
Definition circular_iterator.h:623
ETL_CONSTEXPR14 circular_iterator_impl(const circular_iterator_impl &other)
Copy constructor.
Definition circular_iterator.h:250
ETL_CONSTEXPR14 circular_iterator_impl()
Default constructor.
Definition circular_iterator.h:317
ETL_CONSTEXPR14 circular_iterator_impl()
Default constructor.
Definition circular_iterator.h:226
ETL_CONSTEXPR14 circular_iterator_impl(TIterator itr_begin_, TIterator itr_end_)
Construct from iterators.
Definition circular_iterator.h:234
ETL_CONSTEXPR14 circular_iterator_impl(TIterator itr_begin_, TIterator itr_end_)
Construct from iterators.
Definition circular_iterator.h:325
ETL_CONSTEXPR14 circular_iterator_impl(TIterator itr_begin_, TIterator itr_end_)
Construct from iterators.
Definition circular_iterator.h:447
ETL_CONSTEXPR14 circular_iterator(TIterator itr_begin_, TIterator itr_end_, TIterator start_)
Construct from start + iterators.
Definition circular_iterator.h:631
ETL_CONSTEXPR14 circular_iterator_impl()
Default constructor.
Definition circular_iterator.h:439
Definition circular_iterator.h:597
Definition circular_iterator.h:195
is_same
Definition type_traits_generator.h:1104
bitset_ext
Definition absolute.h:39
ETL_CONSTEXPR14 etl::circular_iterator< TIterator > operator-(etl::circular_iterator< TIterator > &lhs, typename etl::iterator_traits< TIterator >::difference_type offset)
Definition circular_iterator.h:672
bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1151
ETL_CONSTEXPR TContainer::size_type size(const TContainer &container)
Definition iterator.h:1187
bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1139
ETL_CONSTEXPR14 etl::circular_iterator< TIterator > operator+(etl::circular_iterator< TIterator > &lhs, typename etl::iterator_traits< TIterator >::difference_type offset)
Definition circular_iterator.h:659
iterator
Definition iterator.h:399