Embedded Template Library 1.0
Loading...
Searching...
No Matches
deque.h
Go to the documentation of this file.
1
2
3/******************************************************************************
4The MIT License(MIT)
5
6Embedded Template Library.
7https://github.com/ETLCPP/etl
8https://www.etlcpp.com
9
10Copyright(c) 2014 John Wellbelove
11
12Permission is hereby granted, free of charge, to any person obtaining a copy
13of this software and associated documentation files(the "Software"), to deal
14in the Software without restriction, including without limitation the rights
15to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16copies of the Software, and to permit persons to whom the Software is
17furnished to do so, subject to the following conditions :
18
19The above copyright notice and this permission notice shall be included in all
20copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28SOFTWARE.
29******************************************************************************/
30
31#ifndef ETL_DEQUE_INCLUDED
32#define ETL_DEQUE_INCLUDED
33
34#include "platform.h"
35#include "algorithm.h"
36#include "debug_count.h"
37#include "error_handler.h"
38#include "exception.h"
39#include "initializer_list.h"
40#include "iterator.h"
41#include "memory.h"
42#include "placement_new.h"
43#include "type_traits.h"
44#include "utility.h"
45
46#include <stddef.h>
47#include <stdint.h>
48
49#include "private/minmax_push.h"
50
51//*****************************************************************************
55//*****************************************************************************
56
57namespace etl
58{
59 //***************************************************************************
62 //***************************************************************************
63 class deque_exception : public etl::exception
64 {
65 public:
66
67 deque_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
68 : exception(reason_, file_name_, line_number_)
69 {
70 }
71 };
72
73 //***************************************************************************
76 //***************************************************************************
77 class deque_full : public etl::deque_exception
78 {
79 public:
80
81 deque_full(string_type file_name_, numeric_type line_number_)
82 : etl::deque_exception(ETL_ERROR_TEXT("deque:full", ETL_DEQUE_FILE_ID"A"), file_name_, line_number_)
83 {
84 }
85 };
86
87 //***************************************************************************
90 //***************************************************************************
91 class deque_empty : public etl::deque_exception
92 {
93 public:
94
95 deque_empty(string_type file_name_, numeric_type line_number_)
96 : etl::deque_exception(ETL_ERROR_TEXT("deque:empty", ETL_DEQUE_FILE_ID"B"), file_name_, line_number_)
97 {
98 }
99 };
100
101 //***************************************************************************
104 //***************************************************************************
105 class deque_out_of_bounds : public etl::deque_exception
106 {
107 public:
108
109 deque_out_of_bounds(string_type file_name_, numeric_type line_number_)
110 : etl::deque_exception(ETL_ERROR_TEXT("deque:bounds", ETL_DEQUE_FILE_ID"C"), file_name_, line_number_)
111 {
112 }
113 };
114
115 //***************************************************************************
118 //***************************************************************************
119 class deque_incompatible_type : public deque_exception
120 {
121 public:
122
123 deque_incompatible_type(string_type file_name_, numeric_type line_number_)
124 : deque_exception(ETL_ERROR_TEXT("deque:type", ETL_DEQUE_FILE_ID"D"), file_name_, line_number_)
125 {
126 }
127 };
128
129 //***************************************************************************
132 //***************************************************************************
134 {
135 public:
136
137 typedef size_t size_type;
138
139 //*************************************************************************
142 //*************************************************************************
143 size_type size() const
144 {
145 return current_size;
146 }
147
148 //*************************************************************************
151 //*************************************************************************
152 bool empty() const
153 {
154 return (current_size == 0);
155 }
156
157 //*************************************************************************
160 //*************************************************************************
161 bool full() const
162 {
163 return current_size == CAPACITY;
164 }
165
166 //*************************************************************************
169 //*************************************************************************
170 size_type max_size() const
171 {
172 return CAPACITY;
173 }
174
175 //*************************************************************************
178 //*************************************************************************
179 size_type capacity() const
180 {
181 return CAPACITY;
182 }
183
184 //*************************************************************************
187 //*************************************************************************
188 size_t available() const
189 {
190 return max_size() - size();
191 }
192
193 protected:
194
195 //*************************************************************************
197 //*************************************************************************
198 deque_base(size_t max_size_, size_t buffer_size_)
199 : current_size(0)
200 , CAPACITY(max_size_)
201 , Buffer_Size(buffer_size_)
202 {
203 }
204
205 //*************************************************************************
207 //*************************************************************************
209
210 size_type current_size;
211 const size_type CAPACITY;
212 const size_type Buffer_Size;
214 };
215
216 //***************************************************************************
220 //***************************************************************************
221 template <typename T>
222 class ideque : public etl::deque_base
223 {
224 public:
225
226 typedef T value_type;
227 typedef size_t size_type;
228 typedef T& reference;
229 typedef const T& const_reference;
230#if ETL_USING_CPP11
231 typedef T&& rvalue_reference;
232#endif
233 typedef T* pointer;
234 typedef const T* const_pointer;
235 typedef typename etl::iterator_traits<pointer>::difference_type difference_type;
236
237 //*************************************************************************
239 //*************************************************************************
240 class iterator : public etl::iterator<ETL_OR_STD::random_access_iterator_tag, T>
241 {
242 public:
243
244 friend class ideque;
245 friend class const_iterator;
246
247 //***************************************************
248 iterator()
249 : index(0)
250 , p_deque(0)
251 , p_buffer(0)
252 {
253 }
254
255 //***************************************************
256 iterator(const iterator& other)
257 : index(other.index)
258 , p_deque(other.p_deque)
259 , p_buffer(other.p_buffer)
260 {
261 }
262
263 //***************************************************
264 iterator& operator=(const iterator& other)
265 {
266 index = other.index;
267 p_deque = other.p_deque;
268 p_buffer = other.p_buffer;
269
270 return *this;
271 }
272
273 //***************************************************
274 iterator& operator++()
275 {
276 index = (static_cast<size_t>(index) == p_deque->Buffer_Size - 1) ? 0 : index + 1;
277
278 return *this;
279 }
280
281 //***************************************************
282 iterator operator++(int)
283 {
284 iterator previous(*this);
285 index = (static_cast<size_t>(index) == p_deque->Buffer_Size - 1) ? 0 : index + 1;
286
287 return previous;
288 }
289
290 //***************************************************
291 iterator& operator+=(difference_type offset)
292 {
293 if (offset > 0)
294 {
295 index += offset;
296 index = (static_cast<size_t>(index) > p_deque->Buffer_Size - 1) ? index - static_cast<difference_type>(p_deque->Buffer_Size) : index;
297 }
298 else if (offset < 0)
299 {
300 operator-=(-offset);
301 }
302
303 return *this;
304 }
305
306 //***************************************************
307 iterator& operator-=(difference_type offset)
308 {
309 if (offset > 0)
310 {
311 index -= offset;
312 index = (index < 0) ? index + static_cast<difference_type>(p_deque->Buffer_Size) : index;
313 }
314 else if (offset < 0)
315 {
316 operator+=(-offset);
317 }
318
319 return *this;
320 }
321
322 //***************************************************
323 iterator& operator--()
324 {
325 index = (index == 0) ? static_cast<difference_type>(p_deque->Buffer_Size) - 1 : index - 1;
326
327 return *this;
328 }
329
330 //***************************************************
331 iterator operator--(int)
332 {
333 iterator previous(*this);
334 index = (index == 0) ? static_cast<difference_type>(p_deque->Buffer_Size) - 1 : index - 1;
335
336 return previous;
337 }
338
339 //***************************************************
340 reference operator*() const
341 {
342 return p_buffer[index];
343 }
344
345 //***************************************************
346 pointer operator->() const
347 {
348 return &p_buffer[index];
349 }
350
351 //***************************************************
352 reference operator[](size_t i)
353 {
354 iterator result(*this);
355 result += i;
356
357 return *result;
358 }
359
360 //***************************************************
361 const_reference operator[](size_t i) const
362 {
363 iterator result(*this);
364 result += i;
365
366 return *result;
367 }
368
369 //***************************************************
370 friend iterator operator+(const iterator& lhs, difference_type offset)
371 {
372 iterator result(lhs);
373 result += offset;
374 return result;
375 }
376
377 //***************************************************
378 friend iterator operator+(difference_type offset, const iterator& lhs)
379 {
380 iterator result(lhs);
381 result += offset;
382 return result;
383 }
384
385 //***************************************************
386 friend iterator operator-(const iterator& lhs, difference_type offset)
387 {
388 iterator result(lhs);
389 result -= offset;
390 return result;
391 }
392
393 //***************************************************
394 friend bool operator==(const iterator& lhs, const iterator& rhs)
395 {
396 return lhs.index == rhs.index;
397 }
398
399 //***************************************************
400 friend bool operator!=(const iterator& lhs, const iterator& rhs)
401 {
402 return !(lhs == rhs);
403 }
404
405 //***************************************************
406 friend bool operator<(const iterator& lhs, const iterator& rhs)
407 {
408 const difference_type lhs_index = lhs.get_index();
409 const difference_type rhs_index = rhs.get_index();
410 const difference_type reference_index = lhs.container().begin().get_index();
411 const difference_type buffer_size = static_cast<difference_type>(lhs.container().max_size() + 1);
412
413 const difference_type lhs_distance = (lhs_index < reference_index) ? buffer_size + lhs_index - reference_index : lhs_index - reference_index;
414 const difference_type rhs_distance = (rhs_index < reference_index) ? buffer_size + rhs_index - reference_index : rhs_index - reference_index;
415
416 return lhs_distance < rhs_distance;
417 }
418
419 //***************************************************
420 friend bool operator<=(const iterator& lhs, const iterator& rhs)
421 {
422 return !(lhs > rhs);
423 }
424
425 //***************************************************
426 friend bool operator>(const iterator& lhs, const iterator& rhs)
427 {
428 return (rhs < lhs);
429 }
430
431 //***************************************************
432 friend bool operator>=(const iterator& lhs, const iterator& rhs)
433 {
434 return !(lhs < rhs);
435 }
436
437 //***************************************************
438 difference_type get_index() const
439 {
440 return index;
441 }
442
443 //***************************************************
444 ideque& container() const
445 {
446 return *p_deque;
447 }
448
449 //***************************************************
450 pointer get_buffer() const
451 {
452 return p_buffer;
453 }
454
455 //***************************************************
456 void swap(iterator& other)
457 {
458 using ETL_OR_STD::swap; // Allow ADL
459
460 swap(index, other.index);
461 }
462
463 private:
464
465 //***************************************************
466 difference_type distance(difference_type firstIndex, difference_type index_) const
467 {
468 if (index_ < firstIndex)
469 {
470 return static_cast<difference_type>(p_deque->Buffer_Size) + index_ - firstIndex;
471 }
472 else
473 {
474 return index_ - firstIndex;
475 }
476 }
477
478 //***************************************************
479 iterator(difference_type index_, ideque& the_deque, pointer p_buffer_)
480 : index(index_)
481 , p_deque(&the_deque)
482 , p_buffer(p_buffer_)
483 {
484 }
485
486 difference_type index;
487 ideque* p_deque;
488 pointer p_buffer;
489 };
490
491 //*************************************************************************
493 //*************************************************************************
494 class const_iterator : public etl::iterator<ETL_OR_STD::random_access_iterator_tag, const T>
495 {
496 public:
497
498 friend class ideque;
499
500 //***************************************************
501 const_iterator()
502 : index(0)
503 , p_deque(0)
504 , p_buffer(0)
505 {
506 }
507
508 //***************************************************
509 const_iterator(const const_iterator& other)
510 : index(other.index)
511 , p_deque(other.p_deque)
512 , p_buffer(other.p_buffer)
513 {
514 }
515
516 //***************************************************
517 const_iterator(const typename ideque::iterator& other)
518 : index(other.index)
519 , p_deque(other.p_deque)
520 , p_buffer(other.p_buffer)
521 {
522 }
523
524 //***************************************************
525 const_iterator& operator=(const const_iterator& other)
526 {
527 index = other.index;
528 p_deque = other.p_deque;
529 p_buffer = other.p_buffer;
530
531 return *this;
532 }
533
534 const_iterator& operator=(const typename ideque::iterator& other)
535 {
536 index = other.index;
537 p_deque = other.p_deque;
538 p_buffer = other.p_buffer;
539
540 return *this;
541 }
542
543 //***************************************************
544 const_iterator& operator++()
545 {
546 index = (static_cast<size_t>(index) == p_deque->Buffer_Size - 1) ? 0 : index + 1;
547
548 return *this;
549 }
550
551 //***************************************************
552 const_iterator operator++(int)
553 {
554 const_iterator previous(*this);
555 index = (static_cast<size_t>(index) == p_deque->Buffer_Size - 1) ? 0 : index + 1;
556
557 return previous;
558 }
559
560 //***************************************************
561 const_iterator& operator+=(difference_type offset)
562 {
563 if (offset > 0)
564 {
565 index += offset;
566 index = (static_cast<size_t>(index) > p_deque->Buffer_Size - 1) ? index - static_cast<difference_type>(p_deque->Buffer_Size) : index;
567 }
568 else if (offset < 0)
569 {
570 operator-=(-offset);
571 }
572
573 return *this;
574 }
575
576 //***************************************************
577 const_iterator& operator-=(difference_type offset)
578 {
579 if (offset > 0)
580 {
581 index -= offset;
582 index = (index < 0) ? index + static_cast<difference_type>(p_deque->Buffer_Size) : index;
583 }
584 else if (offset < 0)
585 {
586 operator+=(-offset);
587 }
588
589 return *this;
590 }
591
592 //***************************************************
593 const_iterator& operator--()
594 {
595 index = (index == 0) ? static_cast<difference_type>(p_deque->Buffer_Size) - 1 : index - 1;
596
597 return *this;
598 }
599
600 //***************************************************
601 const_iterator operator--(int)
602 {
603 const_iterator previous(*this);
604 index = (index == 0) ? static_cast<difference_type>(p_deque->Buffer_Size) - 1 : index - 1;
605
606 return previous;
607 }
608
609 //***************************************************
610 const_reference operator*() const
611 {
612 return p_buffer[index];
613 }
614
615 //***************************************************
616 const_pointer operator->() const
617 {
618 return &p_buffer[index];
619 }
620
621 //***************************************************
622 reference operator[](size_t i)
623 {
624 iterator result(*this);
625 result += i;
626
627 return *result;
628 }
629
630 //***************************************************
631 friend const_iterator operator+(const const_iterator& lhs, difference_type offset)
632 {
633 const_iterator result(lhs);
634 result += offset;
635 return result;
636 }
637
638 //***************************************************
639 friend const_iterator operator+(difference_type offset, const const_iterator& lhs)
640 {
641 const_iterator result(lhs);
642 result += offset;
643 return result;
644 }
645
646 //***************************************************
647 friend const_iterator operator-(const const_iterator& lhs, difference_type offset)
648 {
649 const_iterator result(lhs);
650 result -= offset;
651 return result;
652 }
653
654 //***************************************************
655 friend bool operator==(const const_iterator& lhs, const const_iterator& rhs)
656 {
657 return lhs.index == rhs.index;
658 }
659
660 //***************************************************
661 friend bool operator!=(const const_iterator& lhs, const const_iterator& rhs)
662 {
663 return !(lhs == rhs);
664 }
665
666 //***************************************************
667 friend bool operator<(const const_iterator& lhs, const const_iterator& rhs)
668 {
669 const difference_type lhs_index = lhs.get_index();
670 const difference_type rhs_index = rhs.get_index();
671 const difference_type reference_index = lhs.container().begin().get_index();
672 const difference_type buffer_size = static_cast<difference_type>(lhs.container().max_size() + 1UL);
673
674 const difference_type lhs_distance = (lhs_index < reference_index) ? buffer_size + lhs_index - reference_index : lhs_index - reference_index;
675 const difference_type rhs_distance = (rhs_index < reference_index) ? buffer_size + rhs_index - reference_index : rhs_index - reference_index;
676
677 return lhs_distance < rhs_distance;
678 }
679
680 //***************************************************
681 friend bool operator<=(const const_iterator& lhs, const const_iterator& rhs)
682 {
683 return !(lhs > rhs);
684 }
685
686 //***************************************************
687 friend bool operator>(const const_iterator& lhs, const const_iterator& rhs)
688 {
689 return (rhs < lhs);
690 }
691
692 //***************************************************
693 friend bool operator>=(const const_iterator& lhs, const const_iterator& rhs)
694 {
695 return !(lhs < rhs);
696 }
697
698 //***************************************************
699 difference_type get_index() const
700 {
701 return index;
702 }
703
704 //***************************************************
705 ideque& container() const
706 {
707 return *p_deque;
708 }
709
710 //***************************************************
711 pointer get_buffer() const
712 {
713 return p_buffer;
714 }
715
716 //***************************************************
717 void swap(const_iterator& other)
718 {
719 ETL_OR_STD::swap(index, other.index);
720 }
721
722 private:
723
724 //***************************************************
725 difference_type distance(difference_type firstIndex, difference_type index_) const
726 {
727 if (index_ < firstIndex)
728 {
729 return static_cast<difference_type>(p_deque->Buffer_Size) + index_ - firstIndex;
730 }
731 else
732 {
733 return index_ - firstIndex;
734 }
735 }
736
737 //***************************************************
738 const_iterator(difference_type index_, ideque& the_deque, pointer p_buffer_)
739 : index(index_)
740 , p_deque(&the_deque)
741 , p_buffer(p_buffer_)
742 {
743 }
744
745 difference_type index;
746 ideque* p_deque;
747 pointer p_buffer;
748 };
749
750 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
751 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
752
753 //*************************************************************************
755 //*************************************************************************
756 template <typename TIterator>
757 typename etl::enable_if<!etl::is_integral<TIterator>::value, void>::type assign(TIterator range_begin, TIterator range_end)
758 {
759 initialise();
760
761 while (range_begin != range_end)
762 {
763 push_back(*range_begin);
764 ++range_begin;
765 }
766 }
767
768 //*************************************************************************
774 //*************************************************************************
775 void assign(size_type n, const value_type& value)
776 {
777 ETL_ASSERT(n <= CAPACITY, ETL_ERROR(deque_full));
778
779 initialise();
780
781 while (n > 0)
782 {
783 create_element_back(value);
784 --n;
785 }
786 }
787
788 //*************************************************************************
793 //*************************************************************************
794 reference at(size_t index)
795 {
796 ETL_ASSERT(index < current_size, ETL_ERROR(deque_out_of_bounds));
797
798 iterator result(_begin);
799 result += static_cast<difference_type>(index);
800
801 return *result;
802 }
803
804 //*************************************************************************
809 //*************************************************************************
810 const_reference at(size_t index) const
811 {
812 ETL_ASSERT(index < current_size, ETL_ERROR(deque_out_of_bounds));
813
814 iterator result(_begin);
815 result += static_cast<difference_type>(index);
816
817 return *result;
818 }
819
820 //*************************************************************************
823 //*************************************************************************
824 reference operator[](size_t index)
825 {
826 iterator result(_begin);
827 result += static_cast<difference_type>(index);
828
829 return *result;
830 }
831
832 //*************************************************************************
835 //*************************************************************************
836 const_reference operator[](size_t index) const
837 {
838 iterator result(_begin);
839 result += static_cast<difference_type>(index);
840
841 return *result;
842 }
843
844 //*************************************************************************
849 //*************************************************************************
850 reference front()
851 {
852 ETL_ASSERT_CHECK_EXTRA(!empty(), ETL_ERROR(deque_empty));
853 return *_begin;
854 }
855
856 //*************************************************************************
861 //*************************************************************************
862 const_reference front() const
863 {
864 ETL_ASSERT_CHECK_EXTRA(!empty(), ETL_ERROR(deque_empty));
865 return *_begin;
866 }
867
868 //*************************************************************************
873 //*************************************************************************
874 reference back()
875 {
876 ETL_ASSERT_CHECK_EXTRA(!empty(), ETL_ERROR(deque_empty));
877 return *(_end - 1);
878 }
879
880 //*************************************************************************
885 //*************************************************************************
886 const_reference back() const
887 {
888 ETL_ASSERT_CHECK_EXTRA(!empty(), ETL_ERROR(deque_empty));
889 return *(_end - 1);
890 }
891
892 //*************************************************************************
894 //*************************************************************************
896 {
897 return _begin;
898 }
899
900 //*************************************************************************
902 //*************************************************************************
904 {
905 return _begin;
906 }
907
908 //*************************************************************************
910 //*************************************************************************
912 {
913 return _begin;
914 }
915
916 //*************************************************************************
918 //*************************************************************************
920 {
921 return iterator(_end);
922 }
923
924 //*************************************************************************
926 //*************************************************************************
928 {
929 return iterator(_end);
930 }
931
932 //*************************************************************************
934 //*************************************************************************
936 {
937 return const_iterator(_end);
938 }
939
940 //*************************************************************************
942 //*************************************************************************
943 reverse_iterator rbegin()
944 {
945 return reverse_iterator(end());
946 }
947
948 //*************************************************************************
950 //*************************************************************************
951 const_reverse_iterator rbegin() const
952 {
953 return const_reverse_iterator(end());
954 }
955
956 //*************************************************************************
958 //*************************************************************************
959 const_reverse_iterator crbegin() const
960 {
961 return const_reverse_iterator(cend());
962 }
963
964 //*************************************************************************
966 //*************************************************************************
967 reverse_iterator rend()
968 {
969 return reverse_iterator(begin());
970 }
971
972 //*************************************************************************
974 //*************************************************************************
975 const_reverse_iterator rend() const
976 {
977 return const_reverse_iterator(begin());
978 }
979
980 //*************************************************************************
982 //*************************************************************************
983 const_reverse_iterator crend() const
984 {
985 return const_reverse_iterator(cbegin());
986 }
987
988 //*************************************************************************
990 //*************************************************************************
991 void clear()
992 {
993 initialise();
994 }
995
996 //*************************************************************************
998 //*************************************************************************
999 void fill(const T& value)
1000 {
1001 etl::fill(begin(), end(), value);
1002 }
1003
1004 //*************************************************************************
1010 //*************************************************************************
1011 iterator insert(const_iterator insert_position, const value_type& value)
1012 {
1013 iterator position(to_iterator(insert_position));
1014
1015 ETL_ASSERT(!full(), ETL_ERROR(deque_full));
1016
1017 if (insert_position == begin())
1018 {
1019 create_element_front(value);
1020 position = _begin;
1021 }
1022 else if (insert_position == end())
1023 {
1024 create_element_back(value);
1025 position = _end - 1;
1026 }
1027 else
1028 {
1029 // Are we closer to the front?
1030 if (etl::distance(_begin, position) < etl::distance(position, _end - 1))
1031 {
1032 // Construct the _begin.
1033 create_element_front(*_begin);
1034
1035 // Move the values.
1036 etl::move(_begin + 1, position, _begin);
1037
1038 // Write the new value.
1039 *--position = value;
1040 }
1041 else
1042 {
1043 // Construct the _end.
1044 create_element_back(*(_end - 1));
1045
1046 // Move the values.
1047 etl::move_backward(position, _end - 2, _end - 1);
1048
1049 // Write the new value.
1050 *position = value;
1051 }
1052 }
1053
1054 return position;
1055 }
1056
1057#if ETL_USING_CPP11
1058 //*************************************************************************
1064 //*************************************************************************
1065 iterator insert(const_iterator insert_position, value_type&& value)
1066 {
1067 iterator position(insert_position.index, *this, p_buffer);
1068
1069 ETL_ASSERT(!full(), ETL_ERROR(deque_full));
1070
1071 if (insert_position == begin())
1072 {
1073 create_element_front(etl::move(value));
1074 position = _begin;
1075 }
1076 else if (insert_position == end())
1077 {
1078 create_element_back(etl::move(value));
1079 position = _end - 1;
1080 }
1081 else
1082 {
1083 // Are we closer to the front?
1084 if (etl::distance(_begin, position) < etl::distance(position, _end - 1))
1085 {
1086 // Construct the _begin.
1087 create_element_front(etl::move(*_begin));
1088
1089 // Move the values.
1090 etl::move(_begin + 1, position, _begin);
1091
1092 // Write the new value.
1093 *--position = etl::move(value);
1094 }
1095 else
1096 {
1097 // Construct the _end.
1098 create_element_back(etl::move(*(_end - 1)));
1099
1100 // Move the values.
1101 etl::move_backward(position, _end - 2, _end - 1);
1102
1103 // Write the new value.
1104 *position = etl::move(value);
1105 }
1106 }
1107
1108 return position;
1109 }
1110#endif
1111
1112 //*************************************************************************
1117 //*************************************************************************
1118#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT
1119 template <typename... Args>
1120 iterator emplace(const_iterator insert_position, Args&&... args)
1121 {
1122 iterator position(insert_position.index, *this, p_buffer);
1123
1124 ETL_ASSERT(!full(), ETL_ERROR(deque_full));
1125
1126 void* p;
1127
1128 if (insert_position == begin())
1129 {
1130 --_begin;
1131 p = etl::addressof(*_begin);
1132 ++current_size;
1133 ETL_INCREMENT_DEBUG_COUNT;
1134 position = _begin;
1135 }
1136 else if (insert_position == end())
1137 {
1138 p = etl::addressof(*_end);
1139 ++_end;
1140 ++current_size;
1141 ETL_INCREMENT_DEBUG_COUNT;
1142 position = _end - 1;
1143 }
1144 else
1145 {
1146 // Are we closer to the front?
1147 if (etl::distance(_begin, position) < etl::distance(position, _end - 1))
1148 {
1149 // Construct the _begin.
1150 create_element_front(*_begin);
1151
1152 // Move the values.
1153 etl::move(_begin + 1, position, _begin);
1154
1155 // Write the new value.
1156 --position;
1157 (*position).~T();
1158 p = etl::addressof(*position);
1159 }
1160 else
1161 {
1162 // Construct the _end.
1163 create_element_back(*(_end - 1));
1164
1165 // Move the values.
1166 etl::move_backward(position, _end - 2, _end - 1);
1167
1168 // Write the new value.
1169 (*position).~T();
1170 p = etl::addressof(*position);
1171 }
1172 }
1173
1174 ::new (p) T(etl::forward<Args>(args)...);
1175
1176 return position;
1177 }
1178
1179#else
1180
1181 //*************************************************************************
1186 //*************************************************************************
1187 template <typename T1>
1188 iterator emplace(const_iterator insert_position, const T1& value1)
1189 {
1190 iterator position(insert_position.index, *this, p_buffer);
1191
1192 ETL_ASSERT(!full(), ETL_ERROR(deque_full));
1193
1194 void* p;
1195
1196 if (insert_position == begin())
1197 {
1198 --_begin;
1199 p = etl::addressof(*_begin);
1200 ++current_size;
1201 ETL_INCREMENT_DEBUG_COUNT;
1202 position = _begin;
1203 }
1204 else if (insert_position == end())
1205 {
1206 p = etl::addressof(*_end);
1207 ++_end;
1208 ++current_size;
1209 ETL_INCREMENT_DEBUG_COUNT;
1210 position = _end - 1;
1211 }
1212 else
1213 {
1214 // Are we closer to the front?
1215 if (etl::distance(_begin, position) < etl::distance(position, _end - 1))
1216 {
1217 // Construct the _begin.
1218 create_element_front(*_begin);
1219
1220 // Move the values.
1221 etl::move(_begin + 1, position, _begin);
1222
1223 // Write the new value.
1224 --position;
1225 (*position).~T();
1226 p = etl::addressof(*position);
1227 }
1228 else
1229 {
1230 // Construct the _end.
1231 create_element_back(*(_end - 1));
1232
1233 // Move the values.
1234 etl::move_backward(position, _end - 2, _end - 1);
1235
1236 // Write the new value.
1237 (*position).~T();
1238 p = etl::addressof(*position);
1239 }
1240 }
1241
1242 ::new (p) T(value1);
1243
1244 return position;
1245 }
1246
1247 //*************************************************************************
1252 //*************************************************************************
1253 template <typename T1, typename T2>
1254 iterator emplace(const_iterator insert_position, const T1& value1, const T2& value2)
1255 {
1256 iterator position(insert_position.index, *this, p_buffer);
1257
1258 ETL_ASSERT(!full(), ETL_ERROR(deque_full));
1259
1260 void* p;
1261
1262 if (insert_position == begin())
1263 {
1264 --_begin;
1265 p = etl::addressof(*_begin);
1266 ++current_size;
1267 ETL_INCREMENT_DEBUG_COUNT;
1268 position = _begin;
1269 }
1270 else if (insert_position == end())
1271 {
1272 p = etl::addressof(*_end);
1273 ++_end;
1274 ++current_size;
1275 ETL_INCREMENT_DEBUG_COUNT;
1276 position = _end - 1;
1277 }
1278 else
1279 {
1280 // Are we closer to the front?
1281 if (etl::distance(_begin, position) < etl::distance(position, _end - 1))
1282 {
1283 // Construct the _begin.
1284 create_element_front(*_begin);
1285
1286 // Move the values.
1287 etl::move(_begin + 1, position, _begin);
1288
1289 // Write the new value.
1290 --position;
1291 (*position).~T();
1292 p = etl::addressof(*position);
1293 }
1294 else
1295 {
1296 // Construct the _end.
1297 create_element_back(*(_end - 1));
1298
1299 // Move the values.
1300 etl::move_backward(position, _end - 2, _end - 1);
1301
1302 // Write the new value.
1303 (*position).~T();
1304 p = etl::addressof(*position);
1305 }
1306 }
1307
1308 ::new (p) T(value1, value2);
1309
1310 return position;
1311 }
1312
1313 //*************************************************************************
1318 //*************************************************************************
1319 template <typename T1, typename T2, typename T3>
1320 iterator emplace(const_iterator insert_position, const T1& value1, const T2& value2, const T3& value3)
1321 {
1322 iterator position(insert_position.index, *this, p_buffer);
1323
1324 ETL_ASSERT(!full(), ETL_ERROR(deque_full));
1325
1326 void* p;
1327
1328 if (insert_position == begin())
1329 {
1330 --_begin;
1331 p = etl::addressof(*_begin);
1332 ++current_size;
1333 ETL_INCREMENT_DEBUG_COUNT;
1334 position = _begin;
1335 }
1336 else if (insert_position == end())
1337 {
1338 p = etl::addressof(*_end);
1339 ++_end;
1340 ++current_size;
1341 ETL_INCREMENT_DEBUG_COUNT;
1342 position = _end - 1;
1343 }
1344 else
1345 {
1346 // Are we closer to the front?
1347 if (etl::distance(_begin, position) < etl::distance(position, _end - 1))
1348 {
1349 // Construct the _begin.
1350 create_element_front(*_begin);
1351
1352 // Move the values.
1353 etl::move(_begin + 1, position, _begin);
1354
1355 // Write the new value.
1356 --position;
1357 (*position).~T();
1358 p = etl::addressof(*position);
1359 }
1360 else
1361 {
1362 // Construct the _end.
1363 create_element_back(*(_end - 1));
1364
1365 // Move the values.
1366 etl::move_backward(position, _end - 2, _end - 1);
1367
1368 // Write the new value.
1369 (*position).~T();
1370 p = etl::addressof(*position);
1371 }
1372 }
1373
1374 ::new (p) T(value1, value2, value3);
1375
1376 return position;
1377 }
1378
1379 //*************************************************************************
1384 //*************************************************************************
1385 template <typename T1, typename T2, typename T3, typename T4>
1386 iterator emplace(const_iterator insert_position, const T1& value1, const T2& value2, const T3& value3, const T4& value4)
1387 {
1388 iterator position(insert_position.index, *this, p_buffer);
1389
1390 ETL_ASSERT(!full(), ETL_ERROR(deque_full));
1391
1392 void* p;
1393
1394 if (insert_position == begin())
1395 {
1396 --_begin;
1397 p = etl::addressof(*_begin);
1398 ++current_size;
1399 ETL_INCREMENT_DEBUG_COUNT;
1400 position = _begin;
1401 }
1402 else if (insert_position == end())
1403 {
1404 p = etl::addressof(*_end);
1405 ++_end;
1406 ++current_size;
1407 ETL_INCREMENT_DEBUG_COUNT;
1408 position = _end - 1;
1409 }
1410 else
1411 {
1412 // Are we closer to the front?
1413 if (etl::distance(_begin, position) < etl::distance(position, _end - 1))
1414 {
1415 // Construct the _begin.
1416 create_element_front(*_begin);
1417
1418 // Move the values.
1419 etl::move(_begin + 1, position, _begin);
1420
1421 // Write the new value.
1422 --position;
1423 (*position).~T();
1424 p = etl::addressof(*position);
1425 }
1426 else
1427 {
1428 // Construct the _end.
1429 create_element_back(*(_end - 1));
1430
1431 // Move the values.
1432 etl::move_backward(position, _end - 2, _end - 1);
1433
1434 // Write the new value.
1435 (*position).~T();
1436 p = etl::addressof(*position);
1437 }
1438 }
1439
1440 ::new (p) T(value1, value2, value3, value4);
1441
1442 return position;
1443 }
1444#endif
1445
1446 //*************************************************************************
1453 //*************************************************************************
1454 iterator insert(const_iterator insert_position, size_type n, const value_type& value)
1455 {
1456 iterator position;
1457
1458 ETL_ASSERT((current_size + n) <= CAPACITY, ETL_ERROR(deque_full));
1459
1460 if (insert_position == begin())
1461 {
1462 for (size_t i = 0UL; i < n; ++i)
1463 {
1464 create_element_front(value);
1465 }
1466
1467 position = _begin;
1468 }
1469 else if (insert_position == end())
1470 {
1471 for (size_t i = 0UL; i < n; ++i)
1472 {
1473 create_element_back(value);
1474 }
1475
1476 position = _end - static_cast<difference_type>(n);
1477 }
1478 else
1479 {
1480 // Non-const insert iterator.
1481 position = iterator(insert_position.index, *this, p_buffer);
1482
1483 // Are we closer to the front?
1484 if (distance(_begin, insert_position) <= difference_type(current_size / 2))
1485 {
1486 size_t n_insert = n;
1487 size_t n_move = static_cast<size_t>(etl::distance(begin(), position));
1488 size_t n_create_copy = etl::min(n_insert, n_move);
1489 size_t n_create_new = (n_insert > n_create_copy) ? n_insert - n_create_copy : 0;
1490 size_t n_copy_new = (n_insert > n_create_new) ? n_insert - n_create_new : 0;
1491 size_t n_copy_old = n_move - n_create_copy;
1492
1493 // Remember the original start.
1494 iterator from = _begin + static_cast<difference_type>(n_create_copy) - 1;
1495 iterator to;
1496
1497 // Create new.
1498 for (size_t i = 0UL; i < n_create_new; ++i)
1499 {
1500 create_element_front(value);
1501 }
1502
1503 // Create copy.
1504 for (size_t i = 0UL; i < n_create_copy; ++i)
1505 {
1506 create_element_front(*from);
1507 --from;
1508 }
1509
1510 // Move old.
1511 from = position - static_cast<difference_type>(n_copy_old);
1512 to = _begin + static_cast<difference_type>(n_create_copy);
1513 etl::move(from, from + static_cast<difference_type>(n_copy_old), to);
1514
1515 // Copy new.
1516 to = position - static_cast<difference_type>(n_create_copy);
1517 etl::fill_n(to, n_copy_new, value);
1518
1519 position = _begin + static_cast<difference_type>(n_move);
1520 }
1521 else
1522 {
1523 size_t n_insert = n;
1524 size_t n_move = static_cast<size_t>(etl::distance(position, end()));
1525 size_t n_create_copy = etl::min(n_insert, n_move);
1526 size_t n_create_new = (n_insert > n_create_copy) ? n_insert - n_create_copy : 0;
1527 size_t n_copy_new = (n_insert > n_create_new) ? n_insert - n_create_new : 0;
1528 size_t n_copy_old = n_move - n_create_copy;
1529
1530 // Create new.
1531 for (size_t i = 0UL; i < n_create_new; ++i)
1532 {
1533 create_element_back(value);
1534 }
1535
1536 // Create copy.
1537 const_iterator from = position + static_cast<difference_type>(n_copy_old);
1538
1539 for (size_t i = 0UL; i < n_create_copy; ++i)
1540 {
1541 create_element_back(*from);
1542 ++from;
1543 }
1544
1545 // Move old.
1546 etl::move_backward(position, position + static_cast<difference_type>(n_copy_old),
1547 position + static_cast<difference_type>(n_insert + n_copy_old));
1548
1549 // Copy new.
1550 etl::fill_n(position, n_copy_new, value);
1551 }
1552 }
1553
1554 return position;
1555 }
1556
1557 //*************************************************************************
1564 //*************************************************************************
1565 template <typename TIterator>
1566 typename enable_if<!etl::is_integral<TIterator>::value, iterator>::type insert(const_iterator insert_position, TIterator range_begin,
1567 TIterator range_end)
1568 {
1569 iterator position;
1570
1571 difference_type n = etl::distance(range_begin, range_end);
1572
1573 ETL_ASSERT((current_size + static_cast<size_t>(n)) <= CAPACITY, ETL_ERROR(deque_full));
1574
1575 if (insert_position == begin())
1576 {
1577 create_element_front(static_cast<size_t>(n), range_begin);
1578
1579 position = _begin;
1580 }
1581 else if (insert_position == end())
1582 {
1583 for (difference_type i = 0; i < n; ++i)
1584 {
1585 create_element_back(*range_begin);
1586 ++range_begin;
1587 }
1588
1589 position = _end - n;
1590 }
1591 else
1592 {
1593 // Non-const insert iterator.
1594 position = iterator(insert_position.index, *this, p_buffer);
1595
1596 // Are we closer to the front?
1597 if (distance(_begin, insert_position) < difference_type(current_size / 2))
1598 {
1599 size_t n_insert = static_cast<size_t>(n);
1600 size_t n_move = static_cast<size_t>(etl::distance(begin(), position));
1601 size_t n_create_copy = etl::min(n_insert, n_move);
1602 size_t n_create_new = (n_insert > n_create_copy) ? n_insert - n_create_copy : 0;
1603 size_t n_copy_new = (n_insert > n_create_new) ? n_insert - n_create_new : 0;
1604 size_t n_copy_old = n_move - n_create_copy;
1605
1606 // Remember the original start.
1607 iterator from;
1608 iterator to;
1609
1610 // Create new.
1611 create_element_front(n_create_new, range_begin);
1612
1613 // Create copy.
1614 create_element_front(n_create_copy, _begin + static_cast<difference_type>(n_create_new));
1615
1616 // Move old.
1617 from = position - static_cast<difference_type>(n_copy_old);
1618 to = _begin + static_cast<difference_type>(n_create_copy);
1619 etl::move(from, from + static_cast<difference_type>(n_copy_old), to);
1620
1621 // Copy new.
1622 to = position - static_cast<difference_type>(n_create_copy);
1623 range_begin += static_cast<difference_type>(n_create_new);
1624 etl::copy(range_begin, range_begin + static_cast<difference_type>(n_copy_new), to);
1625
1626 position = _begin + static_cast<difference_type>(n_move);
1627 }
1628 else
1629 {
1630 size_t n_insert = static_cast<size_t>(n);
1631 size_t n_move = static_cast<size_t>(etl::distance(position, end()));
1632 size_t n_create_copy = etl::min(n_insert, n_move);
1633 size_t n_create_new = (n_insert > n_create_copy) ? n_insert - n_create_copy : 0;
1634 size_t n_copy_new = (n_insert > n_create_new) ? n_insert - n_create_new : 0;
1635 size_t n_copy_old = n_move - n_create_copy;
1636
1637 // Create new.
1638 TIterator item = range_begin + static_cast<difference_type>(n_insert - n_create_new);
1639 for (size_t i = 0UL; i < n_create_new; ++i)
1640 {
1641 create_element_back(*item);
1642 ++item;
1643 }
1644
1645 // Create copy.
1646 const_iterator from = position + static_cast<difference_type>(n_copy_old);
1647
1648 for (size_t i = 0UL; i < n_create_copy; ++i)
1649 {
1650 create_element_back(*from);
1651 ++from;
1652 }
1653
1654 // Move old.
1655 etl::move_backward(position, position + static_cast<difference_type>(n_copy_old),
1656 position + static_cast<difference_type>(n_insert + n_copy_old));
1657
1658 // Copy new.
1659 item = range_begin;
1660 etl::copy(item, item + static_cast<difference_type>(n_copy_new), position);
1661 }
1662 }
1663
1664 return position;
1665 }
1666
1667 //*************************************************************************
1672 //*************************************************************************
1674 {
1675 iterator position(to_iterator(erase_position));
1676 // iterator position(erase_position.index, *this, p_buffer);
1677
1678 ETL_ASSERT(distance(position) <= difference_type(current_size), ETL_ERROR(deque_out_of_bounds));
1679
1680 if (position == _begin)
1681 {
1682 destroy_element_front();
1683 position = begin();
1684 }
1685 else if (position == _end - 1)
1686 {
1687 destroy_element_back();
1688 position = end();
1689 }
1690 else
1691 {
1692 // Are we closer to the front?
1693 if (distance(_begin, position) < difference_type(current_size / 2))
1694 {
1695 etl::move_backward(_begin, position, position + 1);
1696 destroy_element_front();
1697 ++position;
1698 }
1699 else
1700 {
1701 etl::move(position + 1, _end, position);
1702 destroy_element_back();
1703 }
1704 }
1705
1706 return position;
1707 }
1708
1709 //*************************************************************************
1715 //*************************************************************************
1717 {
1718 iterator position(to_iterator(range_begin));
1719
1720 ETL_ASSERT((distance(range_begin) <= difference_type(current_size)) && (distance(range_end) <= difference_type(current_size)),
1721 ETL_ERROR(deque_out_of_bounds));
1722
1723 // How many to erase?
1724 size_t length = static_cast<size_t>(etl::distance(range_begin, range_end));
1725
1726 // At the beginning?
1727 if (position == _begin)
1728 {
1729 for (size_t i = 0UL; i < length; ++i)
1730 {
1731 destroy_element_front();
1732 }
1733
1734 position = begin();
1735 }
1736 // At the end?
1737 else if (position == _end - static_cast<difference_type>(length))
1738 {
1739 for (size_t i = 0UL; i < length; ++i)
1740 {
1741 destroy_element_back();
1742 }
1743
1744 position = end();
1745 }
1746 else
1747 {
1748 // Copy the smallest number of items.
1749 // Are we closer to the front?
1750 if (distance(_begin, position) < difference_type(current_size / 2))
1751 {
1752 // Move the items.
1753 etl::move_backward(_begin, position, position + static_cast<difference_type>(length));
1754
1755 for (size_t i = 0UL; i < length; ++i)
1756 {
1757 destroy_element_front();
1758 }
1759
1760 position += static_cast<difference_type>(length);
1761 }
1762 else
1763 // Must be closer to the back.
1764 {
1765 // Move the items.
1766 etl::move(position + static_cast<difference_type>(length), _end, position);
1767
1768 for (size_t i = 0UL; i < length; ++i)
1769 {
1770 destroy_element_back();
1771 }
1772 }
1773 }
1774
1775 return position;
1776 }
1777
1778 //*************************************************************************
1783 //*************************************************************************
1784 void push_back(const_reference item)
1785 {
1786 ETL_ASSERT_CHECK_PUSH_POP_OR_RETURN(!full(), ETL_ERROR(deque_full));
1787
1788 create_element_back(item);
1789 }
1790
1791#if ETL_USING_CPP11
1792 //*************************************************************************
1797 //*************************************************************************
1798 void push_back(rvalue_reference item)
1799 {
1800 ETL_ASSERT_CHECK_PUSH_POP_OR_RETURN(!full(), ETL_ERROR(deque_full));
1801
1802 create_element_back(etl::move(item));
1803 }
1804#endif
1805
1806#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT
1807 //*************************************************************************
1811 //*************************************************************************
1812 template <typename... Args>
1813 reference emplace_back(Args&&... args)
1814 {
1815 ETL_ASSERT_CHECK_PUSH_POP(!full(), ETL_ERROR(deque_full));
1816
1817 ::new (&(*_end)) T(etl::forward<Args>(args)...);
1818 ++_end;
1819 ++current_size;
1820 ETL_INCREMENT_DEBUG_COUNT;
1821 return back();
1822 }
1823
1824#else
1825
1826 //*************************************************************************
1830 //*************************************************************************
1831 reference emplace_back()
1832 {
1833 ETL_ASSERT_CHECK_PUSH_POP(!full(), ETL_ERROR(deque_full));
1834
1835 ::new (&(*_end)) T();
1836 ++_end;
1837 ++current_size;
1838 ETL_INCREMENT_DEBUG_COUNT;
1839 return back();
1840 }
1841
1842 //*************************************************************************
1846 //*************************************************************************
1847 template <typename T1>
1848 reference emplace_back(const T1& value1)
1849 {
1850 ETL_ASSERT_CHECK_PUSH_POP(!full(), ETL_ERROR(deque_full));
1851
1852 ::new (&(*_end)) T(value1);
1853 ++_end;
1854 ++current_size;
1855 ETL_INCREMENT_DEBUG_COUNT;
1856 return back();
1857 }
1858
1859 //*************************************************************************
1863 //*************************************************************************
1864 template <typename T1, typename T2>
1865 reference emplace_back(const T1& value1, const T2& value2)
1866 {
1867 ETL_ASSERT_CHECK_PUSH_POP(!full(), ETL_ERROR(deque_full));
1868
1869 ::new (&(*_end)) T(value1, value2);
1870 ++_end;
1871 ++current_size;
1872 ETL_INCREMENT_DEBUG_COUNT;
1873 return back();
1874 }
1875
1876 //*************************************************************************
1880 //*************************************************************************
1881 template <typename T1, typename T2, typename T3>
1882 reference emplace_back(const T1& value1, const T2& value2, const T3& value3)
1883 {
1884 ETL_ASSERT_CHECK_PUSH_POP(!full(), ETL_ERROR(deque_full));
1885
1886 ::new (&(*_end)) T(value1, value2, value3);
1887 ++_end;
1888 ++current_size;
1889 ETL_INCREMENT_DEBUG_COUNT;
1890 return back();
1891 }
1892
1893 //*************************************************************************
1897 //*************************************************************************
1898 template <typename T1, typename T2, typename T3, typename T4>
1899 reference emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
1900 {
1901 ETL_ASSERT_CHECK_PUSH_POP(!full(), ETL_ERROR(deque_full));
1902
1903 ::new (&(*_end)) T(value1, value2, value3, value4);
1904 ++_end;
1905 ++current_size;
1906 ETL_INCREMENT_DEBUG_COUNT;
1907 return back();
1908 }
1909#endif
1910
1911 //*************************************************************************
1913 //*************************************************************************
1915 {
1916 ETL_ASSERT_CHECK_PUSH_POP_OR_RETURN(!empty(), ETL_ERROR(deque_empty));
1917
1918 destroy_element_back();
1919 }
1920
1921 //*************************************************************************
1926 //*************************************************************************
1927 void push_front(const_reference item)
1928 {
1929 ETL_ASSERT_CHECK_PUSH_POP_OR_RETURN(!full(), ETL_ERROR(deque_full));
1930
1931 create_element_front(item);
1932 }
1933
1934#if ETL_USING_CPP11
1935 //*************************************************************************
1940 //*************************************************************************
1941 void push_front(rvalue_reference item)
1942 {
1943 ETL_ASSERT_CHECK_PUSH_POP_OR_RETURN(!full(), ETL_ERROR(deque_full));
1944
1945 create_element_front(etl::move(item));
1946 }
1947#endif
1948
1949#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT
1950 //*************************************************************************
1954 //*************************************************************************
1955 template <typename... Args>
1956 reference emplace_front(Args&&... args)
1957 {
1958 ETL_ASSERT_CHECK_PUSH_POP(!full(), ETL_ERROR(deque_full));
1959
1960 --_begin;
1961 ::new (&(*_begin)) T(etl::forward<Args>(args)...);
1962 ++current_size;
1963 ETL_INCREMENT_DEBUG_COUNT;
1964 return front();
1965 }
1966
1967#else
1968
1969 //*************************************************************************
1973 //*************************************************************************
1974 reference emplace_front()
1975 {
1976 ETL_ASSERT_CHECK_PUSH_POP(!full(), ETL_ERROR(deque_full));
1977
1978 --_begin;
1979 ::new (&(*_begin)) T();
1980 ++current_size;
1981 ETL_INCREMENT_DEBUG_COUNT;
1982 return front();
1983 }
1984
1985 //*************************************************************************
1989 //*************************************************************************
1990 template <typename T1>
1991 reference emplace_front(const T1& value1)
1992 {
1993 ETL_ASSERT_CHECK_PUSH_POP(!full(), ETL_ERROR(deque_full));
1994
1995 --_begin;
1996 ::new (&(*_begin)) T(value1);
1997 ++current_size;
1998 ETL_INCREMENT_DEBUG_COUNT;
1999 return front();
2000 }
2001
2002 //*************************************************************************
2006 //*************************************************************************
2007 template <typename T1, typename T2>
2008 reference emplace_front(const T1& value1, const T2& value2)
2009 {
2010 ETL_ASSERT_CHECK_PUSH_POP(!full(), ETL_ERROR(deque_full));
2011
2012 --_begin;
2013 ::new (&(*_begin)) T(value1, value2);
2014 ++current_size;
2015 ETL_INCREMENT_DEBUG_COUNT;
2016 return front();
2017 }
2018
2019 //*************************************************************************
2023 //*************************************************************************
2024 template <typename T1, typename T2, typename T3>
2025 reference emplace_front(const T1& value1, const T2& value2, const T3& value3)
2026 {
2027 ETL_ASSERT_CHECK_PUSH_POP(!full(), ETL_ERROR(deque_full));
2028
2029 --_begin;
2030 ::new (&(*_begin)) T(value1, value2, value3);
2031 ++current_size;
2032 ETL_INCREMENT_DEBUG_COUNT;
2033 return front();
2034 }
2035
2036 //*************************************************************************
2040 //*************************************************************************
2041 template <typename T1, typename T2, typename T3, typename T4>
2042 reference emplace_front(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
2043 {
2044 ETL_ASSERT_CHECK_PUSH_POP(!full(), ETL_ERROR(deque_full));
2045
2046 --_begin;
2047 ::new (&(*_begin)) T(value1, value2, value3, value4);
2048 ++current_size;
2049 ETL_INCREMENT_DEBUG_COUNT;
2050 return front();
2051 }
2052#endif
2053
2054 //*************************************************************************
2056 //*************************************************************************
2058 {
2059 ETL_ASSERT_CHECK_PUSH_POP_OR_RETURN(!empty(), ETL_ERROR(deque_empty));
2060
2061 destroy_element_front();
2062 }
2063
2064 //*************************************************************************
2071 //*************************************************************************
2072 void resize(size_t new_size, const value_type& value = value_type())
2073 {
2074 ETL_ASSERT(new_size <= CAPACITY, ETL_ERROR(deque_full));
2075
2076 // Make it smaller?
2077 if (new_size < current_size)
2078 {
2079 while (current_size > new_size)
2080 {
2081 destroy_element_back();
2082 }
2083 }
2084 // Make it larger?
2085 else if (new_size > current_size)
2086 {
2087 size_t count = new_size - current_size;
2088
2089 for (size_t i = 0UL; i < count; ++i)
2090 {
2091 create_element_back(value);
2092 }
2093 }
2094 }
2095
2096 //*************************************************************************
2098 //*************************************************************************
2099 friend difference_type operator-(const iterator& lhs, const iterator& rhs)
2100 {
2101 return distance(rhs, lhs);
2102 }
2103
2104 //*************************************************************************
2106 //*************************************************************************
2107 friend difference_type operator-(const const_iterator& lhs, const const_iterator& rhs)
2108 {
2109 return distance(rhs, lhs);
2110 }
2111
2112 //*************************************************************************
2114 //*************************************************************************
2116 {
2117 if (&rhs != this)
2118 {
2119 assign(rhs.begin(), rhs.end());
2120 }
2121
2122 return *this;
2123 }
2124
2125#if ETL_USING_CPP11
2126 //*************************************************************************
2128 //*************************************************************************
2129 ideque& operator=(ideque&& rhs)
2130 {
2131 if (&rhs != this)
2132 {
2133 clear();
2134 iterator itr = rhs.begin();
2135 while (itr != rhs.end())
2136 {
2137 push_back(etl::move(*itr));
2138 ++itr;
2139 }
2140
2141 rhs.initialise();
2142 }
2143
2144 return *this;
2145 }
2146#endif
2147
2148#ifdef ETL_IDEQUE_REPAIR_ENABLE
2149 //*************************************************************************
2151 //*************************************************************************
2152 virtual void repair() = 0;
2153#endif
2154
2155 protected:
2156
2157 //*************************************************************************
2159 //*************************************************************************
2160 ideque(pointer p_buffer_, size_t max_size_, size_t buffer_size_)
2161 : deque_base(max_size_, buffer_size_)
2162 , p_buffer(p_buffer_)
2163 {
2164 }
2165
2166 //*********************************************************************
2168 //*********************************************************************
2170 {
2171 if ETL_IF_CONSTEXPR (etl::is_trivially_destructible<T>::value)
2172 {
2173 current_size = 0;
2174 ETL_RESET_DEBUG_COUNT;
2175 }
2176 else
2177 {
2178 while (current_size > 0)
2179 {
2180 destroy_element_back();
2181 }
2182 }
2183
2184 _begin = iterator(0, *this, p_buffer);
2185 _end = iterator(0, *this, p_buffer);
2186 }
2187
2188 //*************************************************************************
2190 //*************************************************************************
2191 void repair_buffer(pointer p_buffer_)
2192 {
2193 p_buffer = p_buffer_;
2194
2195 _begin = iterator(_begin.index, *this, p_buffer);
2196 _end = iterator(_end.index, *this, p_buffer);
2197 }
2198
2199 iterator _begin;
2201 pointer p_buffer;
2202
2203 private:
2204
2205 //*********************************************************************
2207 //*********************************************************************
2208 void create_element_front()
2209 {
2210 --_begin;
2211 ::new (&(*_begin)) T();
2212 ++current_size;
2213 ETL_INCREMENT_DEBUG_COUNT;
2214 }
2215
2216 //*********************************************************************
2218 //*********************************************************************
2219 template <typename TIterator>
2220 void create_element_front(size_t n, TIterator from)
2221 {
2222 if (n == 0)
2223 {
2224 return;
2225 }
2226
2227 _begin -= static_cast<difference_type>(n);
2228
2229 iterator item = _begin;
2230
2231 do {
2232 ::new (&(*item)) T(*from);
2233 ++item;
2234 ++from;
2235 ++current_size;
2236 ETL_INCREMENT_DEBUG_COUNT;
2237 } while (--n != 0);
2238 }
2239
2240 //*********************************************************************
2242 //*********************************************************************
2243 void create_element_back()
2244 {
2245 ::new (&(*_end)) T();
2246 ++_end;
2247 ++current_size;
2248 ETL_INCREMENT_DEBUG_COUNT;
2249 }
2250
2251 //*********************************************************************
2253 //*********************************************************************
2254 void create_element_front(const_reference value)
2255 {
2256 --_begin;
2257 ::new (&(*_begin)) T(value);
2258 ++current_size;
2259 ETL_INCREMENT_DEBUG_COUNT;
2260 }
2261
2262 //*********************************************************************
2264 //*********************************************************************
2265 void create_element_back(const_reference value)
2266 {
2267 ::new (&(*_end)) T(value);
2268 ++_end;
2269 ++current_size;
2270 ETL_INCREMENT_DEBUG_COUNT;
2271 }
2272
2273#if ETL_USING_CPP11
2274 //*********************************************************************
2276 //*********************************************************************
2277 void create_element_front(rvalue_reference value)
2278 {
2279 --_begin;
2280 ::new (&(*_begin)) T(etl::move(value));
2281 ++current_size;
2282 ETL_INCREMENT_DEBUG_COUNT;
2283 }
2284
2285 //*********************************************************************
2287 //*********************************************************************
2288 void create_element_back(rvalue_reference value)
2289 {
2290 ::new (&(*_end)) T(etl::move(value));
2291 ++_end;
2292 ++current_size;
2293 ETL_INCREMENT_DEBUG_COUNT;
2294 }
2295#endif
2296
2297 //*********************************************************************
2299 //*********************************************************************
2300 void destroy_element_front()
2301 {
2302 (*_begin).~T();
2303 --current_size;
2304 ETL_DECREMENT_DEBUG_COUNT;
2305 ++_begin;
2306 }
2307
2308 //*********************************************************************
2310 //*********************************************************************
2311 void destroy_element_back()
2312 {
2313 --_end;
2314 (*_end).~T();
2315 --current_size;
2316 ETL_DECREMENT_DEBUG_COUNT;
2317 }
2318
2319 //*************************************************************************
2321 //*************************************************************************
2322 template <typename TIterator1, typename TIterator2>
2323 static difference_type distance(const TIterator1& range_begin, const TIterator2& range_end)
2324 {
2325 difference_type distance1 = distance(range_begin);
2326 difference_type distance2 = distance(range_end);
2327
2328 return distance2 - distance1;
2329 }
2330
2331 //*************************************************************************
2334 //*************************************************************************
2335 template <typename TIterator>
2336 static difference_type distance(const TIterator& other)
2337 {
2338 const difference_type index = other.get_index();
2339 const difference_type reference_index = other.container()._begin.index;
2340 const difference_type buffer_size = static_cast<difference_type>(other.container().Buffer_Size);
2341
2342 if (index < reference_index)
2343 {
2344 return buffer_size + index - reference_index;
2345 }
2346 else
2347 {
2348 return index - reference_index;
2349 }
2350 }
2351
2352 //*************************************************************************
2354 //*************************************************************************
2355 iterator to_iterator(const_iterator itr) const
2356 {
2357 return iterator(itr.index, const_cast<ideque&>(*this), p_buffer);
2358 }
2359
2360 // Disable copy construction.
2361 ideque(const ideque&);
2362
2363 //*************************************************************************
2365 //*************************************************************************
2366#if defined(ETL_POLYMORPHIC_DEQUE) || defined(ETL_POLYMORPHIC_CONTAINERS) || defined(ETL_IDEQUE_REPAIR_ENABLE)
2367
2368 public:
2369
2370 virtual ~ideque() {}
2371#else
2372
2373 protected:
2374
2376#endif
2377 };
2378
2379 //***************************************************************************
2385 //***************************************************************************
2386 template <typename T, const size_t MAX_SIZE_>
2387 class deque : public etl::ideque<T>
2388 {
2389 public:
2390
2391 static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_;
2392
2393 private:
2394
2395 static ETL_CONSTANT size_t Buffer_Size = MAX_SIZE + 1;
2396
2397 public:
2398
2399 typedef T value_type;
2400 typedef T* pointer;
2401 typedef const T* const_pointer;
2402 typedef T& reference;
2403 typedef const T& const_reference;
2404 typedef size_t size_type;
2405 typedef typename etl::iterator_traits<pointer>::difference_type difference_type;
2406
2407 //*************************************************************************
2409 //*************************************************************************
2411 : etl::ideque<T>(reinterpret_cast<T*>(buffer.raw), MAX_SIZE, Buffer_Size)
2412 {
2413 this->initialise();
2414 }
2415
2416 //*************************************************************************
2418 //*************************************************************************
2420 {
2421 this->initialise();
2422 }
2423
2424 //*************************************************************************
2426 //*************************************************************************
2427 deque(const deque& other)
2428 : etl::ideque<T>(reinterpret_cast<T*>(buffer.raw), MAX_SIZE, Buffer_Size)
2429 {
2430 if (this != &other)
2431 {
2432 this->assign(other.begin(), other.end());
2433 }
2434 }
2435
2436#if ETL_USING_CPP11
2437 //*************************************************************************
2439 //*************************************************************************
2440 deque(deque&& other)
2441 : etl::ideque<T>(reinterpret_cast<T*>(buffer.raw), MAX_SIZE, Buffer_Size)
2442 {
2443 if (this != &other)
2444 {
2445 this->initialise();
2446
2447 typename etl::ideque<T>::iterator itr = other.begin();
2448 while (itr != other.end())
2449 {
2450 this->push_back(etl::move(*itr));
2451 ++itr;
2452 }
2453 }
2454 }
2455#endif
2456
2457 //*************************************************************************
2459 //*************************************************************************
2460 template <typename TIterator>
2461 deque(TIterator begin_, TIterator end_, typename etl::enable_if<!etl::is_integral<TIterator>::value, int>::type = 0)
2462 : etl::ideque<T>(reinterpret_cast<T*>(buffer.raw), MAX_SIZE, Buffer_Size)
2463 {
2464 this->assign(begin_, end_);
2465 }
2466
2467 //*************************************************************************
2469 //*************************************************************************
2470 explicit deque(size_t n, const_reference value = value_type())
2471 : etl::ideque<T>(reinterpret_cast<T*>(buffer.raw), MAX_SIZE, Buffer_Size)
2472 {
2473 this->assign(n, value);
2474 }
2475
2476#if ETL_HAS_INITIALIZER_LIST
2477 //*************************************************************************
2479 //*************************************************************************
2480 deque(std::initializer_list<T> init)
2481 : ideque<T>(reinterpret_cast<T*>(buffer.raw), MAX_SIZE, Buffer_Size)
2482 {
2483 this->assign(init.begin(), init.end());
2484 }
2485#endif
2486
2487 //*************************************************************************
2489 //*************************************************************************
2490 deque& operator=(const deque& rhs)
2491 {
2492 if (&rhs != this)
2493 {
2494 this->assign(rhs.begin(), rhs.end());
2495 }
2496
2497 return *this;
2498 }
2499
2500#if ETL_USING_CPP11
2501 //*************************************************************************
2503 //*************************************************************************
2504 deque& operator=(deque&& rhs)
2505 {
2506 if (&rhs != this)
2507 {
2508 this->clear();
2509 typename etl::ideque<T>::iterator itr = rhs.begin();
2510 while (itr != rhs.end())
2511 {
2512 this->push_back(etl::move(*itr));
2513 ++itr;
2514 }
2515 }
2516
2517 return *this;
2518 }
2519#endif
2520
2521 //*************************************************************************
2523 //*************************************************************************
2524#ifdef ETL_IDEQUE_REPAIR_ENABLE
2525 virtual void repair() ETL_OVERRIDE
2526#else
2527 void repair()
2528#endif
2529 {
2530#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
2531 ETL_ASSERT(etl::is_trivially_copyable<T>::value, ETL_ERROR(etl::deque_incompatible_type));
2532#endif
2533
2534 etl::ideque<T>::repair_buffer(reinterpret_cast<T*>(buffer.raw));
2535 }
2536
2537 private:
2538
2541 };
2542
2543 template <typename T, const size_t MAX_SIZE_>
2544 ETL_CONSTANT size_t deque<T, MAX_SIZE_>::MAX_SIZE;
2545
2546 //*************************************************************************
2548 //*************************************************************************
2549#if ETL_USING_CPP17 && ETL_HAS_INITIALIZER_LIST
2550 template <typename... T>
2551 deque(T...) -> deque<typename etl::common_type_t<T...>, sizeof...(T)>;
2552#endif
2553
2554 //*************************************************************************
2556 //*************************************************************************
2557#if ETL_USING_CPP11 && ETL_HAS_INITIALIZER_LIST
2558 template <typename T, typename... TValues>
2559 constexpr auto make_deque(TValues&&... values) -> etl::deque<T, sizeof...(TValues)>
2560 {
2561 return {etl::forward<T>(values)...};
2562 }
2563#endif
2564
2565 //***************************************************************************
2571 //***************************************************************************
2572 template <typename T>
2573 bool operator==(const etl::ideque<T>& lhs, const etl::ideque<T>& rhs)
2574 {
2575 return (lhs.size() == rhs.size()) && etl::equal(lhs.begin(), lhs.end(), rhs.begin());
2576 }
2577
2578 //***************************************************************************
2584 //***************************************************************************
2585 template <typename T>
2586 bool operator!=(const etl::ideque<T>& lhs, const etl::ideque<T>& rhs)
2587 {
2588 return !(lhs == rhs);
2589 }
2590
2591 //***************************************************************************
2597 //***************************************************************************
2598 template <typename T>
2599 bool operator<(const etl::ideque<T>& lhs, const etl::ideque<T>& rhs)
2600 {
2601 return etl::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
2602 }
2603
2604 //***************************************************************************
2611 //***************************************************************************
2612 template <typename T>
2613 bool operator<=(const etl::ideque<T>& lhs, const etl::ideque<T>& rhs)
2614 {
2615 return !(lhs > rhs);
2616 }
2617
2618 //***************************************************************************
2624 //***************************************************************************
2625 template <typename T>
2626 bool operator>(const etl::ideque<T>& lhs, const etl::ideque<T>& rhs)
2627 {
2628 return (rhs < lhs);
2629 }
2630
2631 //***************************************************************************
2638 //***************************************************************************
2639 template <typename T>
2640 bool operator>=(const etl::ideque<T>& lhs, const etl::ideque<T>& rhs)
2641 {
2642 return !(lhs < rhs);
2643 }
2644} // namespace etl
2645
2646#include "private/minmax_pop.h"
2647
2648#endif
void swap(etl::array_view< T > &lhs, etl::array_view< T > &rhs) ETL_NOEXCEPT
Swaps the values.
Definition array_view.h:692
Const Iterator.
Definition deque.h:495
Iterator.
Definition deque.h:241
Definition memory.h:2728
ETL_CONSTEXPR14 bool operator!=(const etl::bitset< Active_Bits, TElement > &lhs, const etl::bitset< Active_Bits, TElement > &rhs) ETL_NOEXCEPT
Definition bitset_new.h:2529
reference emplace_front(const T1 &value1)
Definition deque.h:1991
reference emplace_back(const T1 &value1, const T2 &value2, const T3 &value3)
Definition deque.h:1882
const_reverse_iterator crbegin() const
Gets a const reverse iterator to the end of the deque.
Definition deque.h:959
void clear()
Clears the deque.
Definition deque.h:991
iterator erase(const_iterator erase_position)
Definition deque.h:1673
const size_type CAPACITY
The maximum number of elements in the deque.
Definition deque.h:211
void pop_back()
Removes the oldest item from the deque.
Definition deque.h:1914
ideque & operator=(const ideque &rhs)
Assignment operator.
Definition deque.h:2115
const_reverse_iterator rbegin() const
Gets a const reverse iterator to the end of the deque.
Definition deque.h:951
ETL_DECLARE_DEBUG_COUNT
Internal debugging.
Definition deque.h:213
void resize(size_t new_size, const value_type &value=value_type())
Definition deque.h:2072
iterator emplace(const_iterator insert_position, const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
Definition deque.h:1386
iterator begin()
Gets an iterator to the beginning of the deque.
Definition deque.h:895
reference front()
Definition deque.h:850
reference at(size_t index)
Definition deque.h:794
reference emplace_back(const T1 &value1, const T2 &value2)
Definition deque.h:1865
pointer p_buffer
Iterator to the _end item in the deque.
Definition deque.h:2201
friend difference_type operator-(const iterator &lhs, const iterator &rhs)
Definition deque.h:2099
reference emplace_front(const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
Definition deque.h:2042
reference emplace_front()
Definition deque.h:1974
etl::enable_if<!etl::is_integral< TIterator >::value, void >::type assign(TIterator range_begin, TIterator range_end)
Assigns a range to the deque.
Definition deque.h:757
void initialise()
Initialise the deque.
Definition deque.h:2169
reference operator[](size_t index)
Definition deque.h:824
~deque_base()
Destructor.
Definition deque.h:208
iterator _end
Iterator to the _begin item in the deque.
Definition deque.h:2200
reference emplace_front(const T1 &value1, const T2 &value2, const T3 &value3)
Definition deque.h:2025
size_type size() const
Definition deque.h:143
const_reference at(size_t index) const
Definition deque.h:810
const_reverse_iterator crend() const
Gets a const reverse iterator to the beginning of the deque.
Definition deque.h:983
const size_type Buffer_Size
The number of elements in the buffer.
Definition deque.h:212
iterator end()
Gets an iterator to the end of the deque.
Definition deque.h:919
const_iterator end() const
Gets a const iterator to the end of the deque.
Definition deque.h:927
void push_front(const_reference item)
Definition deque.h:1927
size_type max_size() const
Definition deque.h:170
~ideque()
Destructor.
Definition deque.h:2375
iterator erase(const_iterator range_begin, const_iterator range_end)
Definition deque.h:1716
iterator emplace(const_iterator insert_position, const T1 &value1)
Definition deque.h:1188
deque(const deque &other)
Copy constructor.
Definition deque.h:2427
friend difference_type operator-(const const_iterator &lhs, const const_iterator &rhs)
Definition deque.h:2107
iterator emplace(const_iterator insert_position, const T1 &value1, const T2 &value2)
Definition deque.h:1254
iterator insert(const_iterator insert_position, size_type n, const value_type &value)
Definition deque.h:1454
enable_if<!etl::is_integral< TIterator >::value, iterator >::type insert(const_iterator insert_position, TIterator range_begin, TIterator range_end)
Definition deque.h:1566
bool full() const
Definition deque.h:161
const_reference operator[](size_t index) const
Definition deque.h:836
size_type capacity() const
Definition deque.h:179
const_reference back() const
Definition deque.h:886
bool empty() const
Definition deque.h:152
void repair()
Fix the internal pointers after a low level memory copy.
Definition deque.h:2527
const_reverse_iterator rend() const
Gets a const reverse iterator to the beginning of the deque.
Definition deque.h:975
const_iterator cend() const
Gets a const iterator to the end of the deque.
Definition deque.h:935
reference emplace_back(const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
Definition deque.h:1899
reference emplace_back()
Definition deque.h:1831
deque_base(size_t max_size_, size_t buffer_size_)
Constructor.
Definition deque.h:198
reference emplace_front(const T1 &value1, const T2 &value2)
Definition deque.h:2008
void assign(size_type n, const value_type &value)
Definition deque.h:775
deque()
Default constructor.
Definition deque.h:2410
reference back()
Definition deque.h:874
iterator emplace(const_iterator insert_position, const T1 &value1, const T2 &value2, const T3 &value3)
Definition deque.h:1320
reverse_iterator rbegin()
Gets a reverse iterator to the end of the deque.
Definition deque.h:943
void fill(const T &value)
Fills the deque.
Definition deque.h:999
void pop_front()
Removes the oldest item from the deque.
Definition deque.h:2057
reference emplace_back(const T1 &value1)
Definition deque.h:1848
void push_back(const_reference item)
Definition deque.h:1784
const_iterator cbegin() const
Gets a const iterator to the beginning of the deque.
Definition deque.h:911
deque(TIterator begin_, TIterator end_, typename etl::enable_if<!etl::is_integral< TIterator >::value, int >::type=0)
Assigns data to the deque.
Definition deque.h:2461
~deque()
Destructor.
Definition deque.h:2419
reverse_iterator rend()
Gets a reverse iterator to the beginning of the deque.
Definition deque.h:967
const_reference front() const
Definition deque.h:862
deque(size_t n, const_reference value=value_type())
Assigns data to the deque.
Definition deque.h:2470
size_t available() const
Definition deque.h:188
deque & operator=(const deque &rhs)
Assignment operator.
Definition deque.h:2490
const_iterator begin() const
Gets a const iterator to the beginning of the deque.
Definition deque.h:903
iterator insert(const_iterator insert_position, const value_type &value)
Definition deque.h:1011
void repair_buffer(pointer p_buffer_)
Fix the internal pointers after a low level memory copy.
Definition deque.h:2191
size_type current_size
The current number of elements in the deque.
Definition deque.h:210
ideque(pointer p_buffer_, size_t max_size_, size_t buffer_size_)
Constructor.
Definition deque.h:2160
Definition deque.h:2388
Definition deque.h:134
Definition deque.h:92
Definition deque.h:64
Definition deque.h:78
Definition deque.h:106
Definition deque.h:223
#define ETL_ASSERT(b, e)
Definition error_handler.h:511
ETL_EXCEPTION_CONSTEXPR exception(string_type reason_, string_type, numeric_type)
Constructor.
Definition exception.h:81
Definition exception.h:59
ETL_CONSTEXPR17 etl::enable_if<!etl::is_same< T, etl::nullptr_t >::value, T >::type * addressof(T &t)
Definition addressof.h:52
Definition deque.h:120
bitset_ext
Definition absolute.h:40
ETL_CONSTEXPR14 bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1081
bool operator>(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1133
bool operator>=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1147
ETL_CONSTEXPR14 bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1093
bool operator<(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1106
bool operator<=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1120
iterator
Definition iterator.h:424