31#ifndef ETL_MULTI_SPAN_INCLUDED
32#define ETL_MULTI_SPAN_INCLUDED
51 typedef T element_type;
52 typedef typename etl::remove_cv<T>::type value_type;
53 typedef size_t size_type;
55 typedef const T& const_reference;
57 typedef const T* const_pointer;
65 class iterator :
public etl::iterator<ETL_OR_STD::bidirectional_iterator_tag, element_type>
69 friend class multi_span;
70 friend class const_iterator;
73 ETL_CONSTEXPR14 iterator()
74 : p_span_list(ETL_NULLPTR)
75 , p_current_span(ETL_NULLPTR)
76 , p_value(ETL_NULLPTR)
81 ETL_CONSTEXPR14 iterator(
const iterator& other)
82 : p_span_list(other.p_span_list)
83 , p_current_span(other.p_current_span)
84 , p_value(other.p_value)
89 ETL_CONSTEXPR14 iterator& operator =(
const iterator& rhs)
91 p_span_list = rhs.p_span_list;
92 p_current_span = rhs.p_current_span;
93 p_value = rhs.p_value;
99 ETL_CONSTEXPR14 iterator& operator ++()
101 if (p_current_span != p_span_list->end())
105 if (p_value == p_current_span->end())
110 }
while ((p_current_span != p_span_list->end()) && p_current_span->empty());
112 if (p_current_span != p_span_list->end())
114 p_value = p_current_span->begin();
118 p_value = ETL_NULLPTR;
127 ETL_CONSTEXPR14 iterator operator ++(
int)
129 iterator temp = *
this;
137 ETL_CONSTEXPR14 iterator& operator --()
139 if (p_current_span == p_span_list->end())
142 p_value = p_current_span->end();
145 else if ((p_current_span != p_span_list->begin()) || (p_value != p_current_span->begin()))
147 if (p_value == p_current_span->begin())
152 }
while ((p_current_span != p_span_list->begin()) && p_current_span->empty());
154 p_value = p_current_span->end();
164 p_value = ETL_NULLPTR;
171 ETL_CONSTEXPR14 iterator operator --(
int)
173 iterator temp = *
this;
215 ETL_CONSTEXPR14
friend bool operator ==(
const iterator& lhs,
const iterator& rhs)
217 return (lhs.p_current_span == rhs.p_current_span) && (lhs.p_value == rhs.p_value);
223 ETL_CONSTEXPR14
friend bool operator !=(
const iterator& lhs,
const iterator& rhs)
225 return !(lhs == rhs);
230 typedef const span_type* span_pointer;
231 typedef const span_list_type* span_list_pointer;
232 typedef typename span_list_type::iterator span_list_iterator;
235 ETL_CONSTEXPR14
iterator(
const span_list_type& span_list_, span_list_iterator p_current_span_)
236 : p_span_list(&span_list_)
237 , p_current_span(p_current_span_)
238 , p_value(ETL_NULLPTR)
240 if (p_current_span != p_span_list->
end())
242 while ((p_current_span != p_span_list->end()) && p_current_span->empty())
247 if (p_current_span != p_span_list->
end())
249 p_value = p_current_span->begin();
253 p_value = ETL_NULLPTR;
258 span_list_pointer p_span_list;
259 span_pointer p_current_span;
266 class const_iterator :
public etl::iterator<ETL_OR_STD::bidirectional_iterator_tag, const element_type>
270 friend class multi_span;
273 ETL_CONSTEXPR14 const_iterator()
274 : p_span_list(ETL_NULLPTR)
275 , p_current_span(ETL_NULLPTR)
276 , p_value(ETL_NULLPTR)
281 ETL_CONSTEXPR14 const_iterator(
const const_iterator& other)
282 : p_span_list(other.p_span_list)
283 , p_current_span(other.p_current_span)
284 , p_value(other.p_value)
289 ETL_CONSTEXPR14 const_iterator& operator =(
const const_iterator& rhs)
291 p_span_list = rhs.p_span_list;
292 p_current_span = rhs.p_current_span;
293 p_value = rhs.p_value;
300 : p_span_list(other.p_span_list)
301 , p_current_span(other.p_current_span)
302 , p_value(other.p_value)
309 p_span_list = rhs.p_span_list;
310 p_current_span = rhs.p_current_span;
311 p_value = rhs.p_value;
317 ETL_CONSTEXPR14 const_iterator& operator ++()
319 if (p_current_span != p_span_list->end())
323 if (p_value == p_current_span->end())
328 }
while ((p_current_span != p_span_list->end()) && p_current_span->empty());
330 if (p_current_span != p_span_list->end())
332 p_value = p_current_span->begin();
336 p_value = ETL_NULLPTR;
345 ETL_CONSTEXPR14 const_iterator operator ++(
int)
347 const_iterator temp = *
this;
355 ETL_CONSTEXPR14 const_iterator& operator --()
357 if (p_current_span == p_span_list->end())
360 p_value = p_current_span->end();
363 else if ((p_current_span != p_span_list->begin()) || (p_value != p_current_span->begin()))
365 if (p_value == p_current_span->begin())
370 }
while ((p_current_span != p_span_list->begin()) && p_current_span->empty());
372 p_value = p_current_span->end();
382 p_value = ETL_NULLPTR;
389 ETL_CONSTEXPR14 const_iterator operator --(
int)
391 const_iterator temp = *
this;
409 ETL_CONSTEXPR14 const_pointer operator ->()
const
417 ETL_CONSTEXPR14
friend bool operator ==(
const const_iterator& lhs,
const const_iterator& rhs)
419 return (lhs.p_current_span == rhs.p_current_span) && (lhs.p_value == rhs.p_value);
425 ETL_CONSTEXPR14
friend bool operator !=(
const const_iterator& lhs,
const const_iterator& rhs)
427 return !(lhs == rhs);
432 typedef const span_type* span_pointer;
433 typedef const span_list_type* span_list_pointer;
434 typedef const typename span_list_type::iterator span_list_iterator;
437 ETL_CONSTEXPR14
const_iterator(
const span_list_type& span_list_, span_list_iterator p_current_span_)
438 : p_span_list(&span_list_)
439 , p_current_span(p_current_span_)
440 , p_value(ETL_NULLPTR)
442 if (p_current_span != p_span_list->end())
444 while ((p_current_span != p_span_list->end()) && p_current_span->empty())
449 if (p_current_span != p_span_list->end())
451 p_value = p_current_span->begin();
455 p_value = ETL_NULLPTR;
460 span_list_pointer p_span_list;
461 span_pointer p_current_span;
462 const_pointer p_value;
465 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
466 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
472 : span_list(span_list_)
480 template <
typename TContainer>
482 : span_list(a.data(), a.data() + a.size())
490 template <
typename TContainer>
492 : span_list(a.data(), a.data() + a.size())
499 template <
typename TIterator>
508 template <
typename TIterator>
518 : span_list(other.span_list)
527 span_list = other.span_list;
537 return iterator(span_list, span_list.begin());
543 ETL_CONSTEXPR14 const_iterator cbegin()
const
545 return const_iterator(span_list, span_list.cbegin());
551 ETL_CONSTEXPR14 iterator
end()
const
553 return iterator(span_list, span_list.end());
559 ETL_CONSTEXPR14 const_iterator
cend()
const
561 return const_iterator(span_list, span_list.cend());
567 ETL_CONSTEXPR14 reverse_iterator
rbegin()
const
569 return reverse_iterator(
end());
575 ETL_CONSTEXPR14 reverse_iterator
crbegin()
const
577 return const_reverse_iterator(
cend());
583 ETL_CONSTEXPR14 reverse_iterator
rend()
const
585 return reverse_iterator(
begin());
591 ETL_CONSTEXPR14 const_reverse_iterator
crend()
const
593 return const_reverse_iterator(
cbegin());
602 size_t number_of_spans = span_list.size();
606 while ((i >= span_list[index].
size()) && (index < number_of_spans))
608 i -= span_list[index].size();
612 return span_list[index][i];
618 ETL_CONSTEXPR14
size_t size() const ETL_NOEXCEPT
620 size_t total_n_spans = 0U;
622 for (
typename span_list_type::iterator itr = span_list.begin();
623 itr != span_list.end();
626 total_n_spans += itr->size();
629 return total_n_spans;
635 ETL_CONSTEXPR14
bool empty() const ETL_NOEXCEPT
637 if (span_list.empty())
652 size_t total_n_spans_bytes = 0U;
654 for (
typename span_list_type::iterator itr = span_list.begin();
655 itr != span_list.end();
658 total_n_spans_bytes += itr->size_bytes();
661 return total_n_spans_bytes;
669 return span_list.size();
674 span_list_type span_list;
Const Iterator.
Definition multi_span.h:267
Iterator.
Definition multi_span.h:66
ETL_CONSTEXPR14 reference operator*()
Definition multi_span.h:183
ETL_CONSTEXPR14 friend bool operator==(const iterator &lhs, const iterator &rhs)
== operator
Definition multi_span.h:215
ETL_CONSTEXPR14 pointer operator->()
-> operator
Definition multi_span.h:199
ETL_CONSTEXPR14 friend bool operator!=(const iterator &lhs, const iterator &rhs)
!= operator
Definition multi_span.h:223
ETL_CONSTEXPR14 multi_span(TIterator begin_, size_t length_)
Constructor.
Definition multi_span.h:509
ETL_CONSTEXPR14 multi_span(const multi_span &other)
Copy Constructor.
Definition multi_span.h:517
ETL_CONSTEXPR14 size_t size_spans() const ETL_NOEXCEPT
Returns the number of spans in the multi_span.
Definition multi_span.h:667
ETL_CONSTEXPR14 reference operator[](size_t i) const
Returns a reference to the indexed value.
Definition multi_span.h:599
ETL_CONSTEXPR14 size_t size() const ETL_NOEXCEPT
Returns the number of elements in the multi_span.
Definition multi_span.h:618
ETL_CONSTEXPR14 multi_span(const TContainer &a) ETL_NOEXCEPT
Definition multi_span.h:491
ETL_CONSTEXPR14 multi_span(TIterator begin_, TIterator end_)
Constructor.
Definition multi_span.h:500
ETL_CONSTEXPR14 multi_span(span_list_type span_list_)
Constructor.
Definition multi_span.h:471
ETL_CONSTEXPR14 size_t size_bytes() const ETL_NOEXCEPT
Returns the size of the multi_span.
Definition multi_span.h:650
ETL_CONSTEXPR14 multi_span(TContainer &a) ETL_NOEXCEPT
Definition multi_span.h:481
ETL_CONSTEXPR14 bool empty() const ETL_NOEXCEPT
Returns true if the multi_span size is zero.
Definition multi_span.h:635
Span - Fixed Extent.
Definition span.h:138
ETL_NODISCARD ETL_CONSTEXPR iterator end() const ETL_NOEXCEPT
Returns an iterator to the end of the span.
Definition span.h:374
bitset_ext
Definition absolute.h:39
ETL_CONSTEXPR TContainer::reverse_iterator rend(TContainer &container)
Definition iterator.h:1114
ETL_CONSTEXPR TContainer::const_reverse_iterator crbegin(const TContainer &container)
Definition iterator.h:1104
ETL_CONSTEXPR TContainer::reverse_iterator rbegin(TContainer &container)
Definition iterator.h:1084
ETL_CONSTEXPR TContainer::const_iterator cbegin(const TContainer &container)
Definition iterator.h:982
bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1151
ETL_CONSTEXPR T * to_address(T *p) ETL_NOEXCEPT
Definition memory.h:62
bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1139
ETL_CONSTEXPR TContainer::iterator begin(TContainer &container)
Definition iterator.h:962
ETL_CONSTEXPR14 enable_if<!etl::is_specialization< TRep2, etl::chrono::duration >::value, etl::chrono::duration< typenameetl::common_type< TRep1, TRep2 >::type, TPeriod1 > >::type operator*(const etl::chrono::duration< TRep1, TPeriod1 > &lhs, const TRep2 &rhs) ETL_NOEXCEPT
Operator *.
Definition duration.h:545
ETL_CONSTEXPR TContainer::const_reverse_iterator crend(const TContainer &container)
Definition iterator.h:1134
ETL_CONSTEXPR TContainer::const_iterator cend(const TContainer &container)
Definition iterator.h:1012
ETL_CONSTEXPR TContainer::iterator end(TContainer &container)
Definition iterator.h:992
iterator
Definition iterator.h:399