Embedded Template Library  1.0
 All Classes Files Functions Variables Typedefs Friends Modules Pages
iforward_list.h
Go to the documentation of this file.
1 
3 /******************************************************************************
4 The MIT License(MIT)
5 
6 Embedded Template Library.
7 
8 Copyright(c) 2014 jwellbelove
9 
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files(the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions :
16 
17 The above copyright notice and this permission notice shall be included in all
18 copies or substantial portions of the Software.
19 
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 SOFTWARE.
27 ******************************************************************************/
28 
29 #ifndef __ETL_ILIST__
30 #define __ETL_ILIST__
31 #define __ETL_IN_ILIST_H__
32 
33 #if WIN32
34 #undef min
35 #endif
36 
37 #include <iterator>
38 #include <algorithm>
39 #include <functional>
40 #include <stddef.h>
41 
42 #include "nullptr.h"
43 #include "forward_list_base.h"
44 #include "type_traits.h"
45 #include "parameter_type.h"
46 
47 namespace etl
48 {
49  //***************************************************************************
52  //***************************************************************************
53  template <typename T>
55  {
56  public:
57 
58  typedef T value_type;
59  typedef T* pointer;
60  typedef const T* const_pointer;
61  typedef T& reference;
62  typedef const T& const_reference;
63  typedef size_t size_type;
64 
65  protected:
66 
67  typedef typename parameter_type<T, is_fundamental<T>::value || is_pointer<T>::value>::type parameter_t;
68 
69  //*************************************************************************
71  //*************************************************************************
72  struct Data_Node;
73 
74  struct Node
75  {
76  Node()
77  : next(nullptr)
78  {
79  }
80 
81  void mark_as_free()
82  {
83  next = nullptr;
84  }
85 
86  bool is_free() const
87  {
88  return next == nullptr;
89  }
90 
91  Node* next;
92  };
93 
94  //*************************************************************************
96  //*************************************************************************
97  struct Data_Node : public Node
98  {
99  T value;
100  };
101 
102  public:
103 
104  //*************************************************************************
106  //*************************************************************************
107  class iterator : public std::iterator<std::forward_iterator_tag, T>
108  {
109  public:
110 
111  friend class iforward_list;
112 
113  iterator()
114  : p_node(nullptr)
115  {
116  }
117 
118  iterator(Node& node)
119  : p_node(&node)
120  {
121  }
122 
123  iterator(const iterator& other)
124  : p_node(other.p_node)
125  {
126  }
127 
128  iterator& operator ++()
129  {
130  p_node = p_node->next;
131  return *this;
132  }
133 
134  iterator operator ++(int)
135  {
136  iterator temp(*this);
137  p_node = p_node->next;
138  return temp;
139  }
140 
141  iterator operator =(const iterator& other)
142  {
143  p_node = other.p_node;
144  return *this;
145  }
146 
147  reference operator *()
148  {
149  return iforward_list::data_cast(p_node)->value;
150  }
151 
152  const_reference operator *() const
153  {
154  return iforward_list::data_cast(p_node)->value;
155  }
156 
157  pointer operator &()
158  {
159  return &(iforward_list::data_cast(p_node)->value);
160  }
161 
162  const_pointer operator &() const
163  {
164  return &(iforward_list::data_cast(p_node)->value);
165  }
166 
167  pointer operator ->()
168  {
169  return &(iforward_list::data_cast(p_node)->value);
170  }
171 
172  const_pointer operator ->() const
173  {
174  return &(iforward_list::data_cast(p_node)->value);
175  }
176 
177  friend bool operator == (const iterator& lhs, const iterator& rhs)
178  {
179  return lhs.p_node == rhs.p_node;
180  }
181 
182  friend bool operator != (const iterator& lhs, const iterator& rhs)
183  {
184  return !(lhs == rhs);
185  }
186 
187  private:
188 
189  Node* p_node;
190  };
191 
192  //*************************************************************************
194  //*************************************************************************
195  class const_iterator : public std::iterator<std::forward_iterator_tag, const T>
196  {
197  public:
198 
199  friend class iforward_list;
200 
202  : p_node(nullptr)
203  {
204  }
205 
206  const_iterator(Node& node)
207  : p_node(&node)
208  {
209  }
210 
211  const_iterator(const Node& node)
212  : p_node(&node)
213  {
214  }
215 
216  const_iterator(const typename iforward_list::iterator& other)
217  : p_node(other.p_node)
218  {
219  }
220 
221  const_iterator(const const_iterator& other)
222  : p_node(other.p_node)
223  {
224  }
225 
226  const_iterator& operator ++()
227  {
228  p_node = p_node->next;
229  return *this;
230  }
231 
232  const_iterator operator ++(int)
233  {
234  const_iterator temp(*this);
235  p_node = p_node->next;
236  return temp;
237  }
238 
239  const_iterator operator =(const const_iterator& other)
240  {
241  p_node = other.p_node;
242  return *this;
243  }
244 
245  const_reference operator *() const
246  {
247  return iforward_list::data_cast(p_node)->value;
248  }
249 
250  const_pointer operator &() const
251  {
252  return iforward_list::data_cast(p_node)->value;
253  }
254 
255  const_pointer operator ->() const
256  {
257  return &(iforward_list::data_cast(p_node)->value);
258  }
259 
260  friend bool operator == (const const_iterator& lhs, const const_iterator& rhs)
261  {
262  return lhs.p_node == rhs.p_node;
263  }
264 
265  friend bool operator != (const const_iterator& lhs, const const_iterator& rhs)
266  {
267  return !(lhs == rhs);
268  }
269 
270  private:
271 
272  const Node* p_node;
273  };
274 
275  typedef typename std::iterator_traits<iterator>::difference_type difference_type;
276 
277  //*************************************************************************
279  //*************************************************************************
281  {
282  return iterator(data_cast(get_head()));
283  }
284 
285  //*************************************************************************
287  //*************************************************************************
289  {
290  return const_iterator(data_cast(get_head()));
291  }
292 
293  //*************************************************************************
295  //*************************************************************************
297  {
298  return iterator(static_cast<Data_Node&>(start_node));
299  }
300 
301  //*************************************************************************
303  //*************************************************************************
305  {
306  return const_iterator(static_cast<const Data_Node&>(start_node));
307  }
308 
309  //*************************************************************************
311  //*************************************************************************
313  {
314  return const_iterator(get_head());
315  }
316 
317  //*************************************************************************
319  //*************************************************************************
321  {
322  return iterator(end_node);
323  }
324 
325  //*************************************************************************
327  //*************************************************************************
329  {
330  return const_iterator(static_cast<const Data_Node&>(end_node));
331  }
332 
333  //*************************************************************************
335  //*************************************************************************
337  {
338  return const_iterator(static_cast<const Data_Node&>(end_node));
339  }
340 
341  //*************************************************************************
343  //*************************************************************************
345  {
346  assign(rhs.cbegin(), rhs.cend());
347 
348  return *this;
349  }
350 
351  //*************************************************************************
353  //*************************************************************************
354  void clear()
355  {
356  initialise();
357  }
358 
359  //*************************************************************************
361  //*************************************************************************
362  reference front()
363  {
364  return data_cast(get_head()).value;
365  }
366 
367  //*************************************************************************
369  //*************************************************************************
370  const_reference front() const
371  {
372  return data_cast(get_head()).value;
373  }
374 
375  //*************************************************************************
379  //*************************************************************************
380  template <typename TIterator>
381  void assign(TIterator first, TIterator last)
382  {
383  // Reset the links.
384  join(start_node, end_node);
385  join(end_node, start_node);
386 
387  size_t i = 0;
388  Node* p_last_node = &start_node;
389 
390  // Add all of the elements.
391  while (first != last)
392  {
393  if (i < MAX_SIZE)
394  {
395  Data_Node& data_node = node_pool[i++];
396  data_node.value = *first++;
397  join(*p_last_node, data_node);
398  join(data_node, end_node);
399  p_last_node = &data_node;
400  }
401  else
402 #ifdef ETL_THROW_EXCEPTIONS
403  {
404  throw forward_list_full();
405  }
406 #else
407  {
409  }
410 #endif
411  }
412 
413  next_free = i;
414  count = i;
415 
416  // Clear the remaining elements in the node pool.
417  while (i < MAX_SIZE)
418  {
419  node_pool[i].mark_as_free();
420  ++i;
421  }
422  }
423 
424  //*************************************************************************
426  //*************************************************************************
427  void assign(size_t n, parameter_t value)
428  {
429  // Reset the links.
430  join(start_node, end_node);
431  join(end_node, start_node);
432 
433  size_t i = 0;
434  Node* p_last_node = &start_node;
435 
436  // Add all of the elements.
437  while (i < n)
438  {
439  if (i < MAX_SIZE)
440  {
441  Data_Node& data_node = node_pool[i++];
442  data_node.value = value;
443  join(*p_last_node, data_node);
444  join(data_node, end_node);
445  p_last_node = &data_node;
446  }
447  else
448 #ifdef ETL_THROW_EXCEPTIONS
449  {
450  throw forward_list_full();
451  }
452 #else
453  {
455  }
456 #endif
457  }
458 
459  next_free = i;
460  count = i;
461 
462  // Clear the remaining elements in the node pool.
463  while (i < MAX_SIZE)
464  {
465  node_pool[i].mark_as_free();
466  ++i;
467  }
468  }
469 
470  //*************************************************************************
472  //*************************************************************************
473  void push_front()
474  {
475  if (!full())
476  {
477  Data_Node& data_node = node_pool[next_free];
478 
479  insert_node(get_head(), data_node);
480  }
481  else
482 #ifdef ETL_THROW_EXCEPTIONS
483  {
484  throw forward_list_full();
485  }
486 #else
487  {
489  }
490 #endif
491  }
492 
493  //*************************************************************************
495  //*************************************************************************
496  void push_front(parameter_t value)
497  {
498  if (!full())
499  {
500  Data_Node& data_node = node_pool[next_free];
501  data_node.value = value;
502 
503  insert_node_after(get_head(), data_node);
504  }
505  else
506 #ifdef ETL_THROW_EXCEPTIONS
507  {
508  throw forward_list_full();
509  }
510 #else
511  {
513  }
514 #endif
515  }
516 
517  //*************************************************************************
519  //*************************************************************************
520  void pop_front()
521  {
522  if (!empty())
523  {
524  remove_node_after(start_node);
525  }
526  }
527 
528  //*************************************************************************
530  //*************************************************************************
531  void resize(size_t n)
532  {
533  resize(n, T());
534  }
535 
536  //*************************************************************************
540  //*************************************************************************
541  void resize(size_t n, T value)
542  {
543  if (n <= MAX_SIZE)
544  {
545  size_t i = 0;
546  iterator i_node = begin();
547 
548  // Find where we're currently at.
549  while ((i < n) && (i_node != end()))
550  {
551  ++i;
552  ++i_node;
553  }
554 
555  if (i_node != end())
556  {
557  // Reduce.
558  erase_after(i_node, end());
559  }
560  else if (i_node == end())
561  {
562  while (i < n)
563  {
564  i_node = insert_after(i_node, value);
565  ++i;
566  }
567  }
568  }
569  else
570 #ifdef ETL_THROW_EXCEPTIONS
571  {
572  throw forward_list_full();
573  }
574 #else
575  {
577  }
578 #endif
579  }
580 
581  //*************************************************************************
583  //*************************************************************************
584  void reverse()
585  {
586  if (is_trivial_list())
587  {
588  return;
589  }
590 
591  Node* p_last = &start_node;
592  Node* p_current = p_last->next;
593  Node* p_next = p_current->next;
594 
595  join(*p_current, end_node);
596 
597  while (p_next != &end_node)
598  {
599  p_last = p_current;
600  p_current = p_next;
601  p_next = p_current->next;
602 
603  p_current->next = static_cast<Data_Node*>(p_last);
604  }
605 
606  join(start_node, *p_current);
607  }
608 
609  //*************************************************************************
611  //*************************************************************************
612  iterator insert_after(iterator position, parameter_t value)
613  {
614  if (!full())
615  {
616  Data_Node& data_node = node_pool[next_free];
617  data_node.value = value;
618 
619  insert_node_after(*position.p_node, data_node);
620 
621  return iterator(data_node);
622  }
623  else
624 #ifdef ETL_THROW_EXCEPTIONS
625  {
626  throw forward_list_full();
627  return end();
628  }
629 #else
630  {
632  return end();
633  }
634 #endif
635  }
636 
637  //*************************************************************************
639  //*************************************************************************
640  void insert_after(iterator position, size_t n, parameter_t value)
641  {
642  if (!full())
643  {
644  for (size_t i = 0; !full() && (i < n); ++i)
645  {
646  // Set up the next free node.
647  Data_Node& data_node = node_pool[next_free];
648  data_node.value = value;
649 
650  insert_node(*position.p_node, data_node);
651  }
652  }
653  else
654 #ifdef ETL_THROW_EXCEPTIONS
655  {
656  throw forward_list_full();
657  }
658 #else
659  {
661  }
662 #endif
663  }
664 
665  //*************************************************************************
667  //*************************************************************************
668  template <typename TIterator>
669  void insert_after(iterator position, TIterator first, TIterator last)
670  {
671  while (first != last)
672  {
673  if (!full())
674  {
675  // Set up the next free node.
676  Data_Node& data_node = node_pool[next_free];
677  data_node.value = *first;
678 
679  insert_node_after(*position.p_node, data_node);
680  ++first;
681  ++position;
682  }
683  else
684 #ifdef ETL_THROW_EXCEPTIONS
685  {
686  throw forward_list_full();
687  }
688 #else
689  {
691  }
692 #endif
693  }
694  }
695 
696  //*************************************************************************
698  //*************************************************************************
700  {
701  iterator next(position);
702  ++next;
703  ++next;
704 
705  remove_node_after(*position.p_node);
706 
707  return next;
708  }
709 
710  //*************************************************************************
712  //*************************************************************************
714  {
715  Node* p_first = first.p_node;
716  Node* p_last = last.p_node;
717  Node* p_next = p_first->next;
718 
719  // Join the ends.
720  join(*p_first, *p_last);
721 
722  p_first = p_next;
723 
724  // Erase the ones in between.
725  while (p_first != p_last)
726  {
727  // Update the position of the earliest free node in the pool.
728  size_t new_free = std::distance(&node_pool[0], static_cast<Data_Node*>(p_first));
729  next_free = std::min(next_free, new_free);
730 
731  // One less.
732  --count;
733 
734  p_next = p_first->next; // Remember the next node.
735  p_first->mark_as_free(); // Free the current node.
736  p_first = p_next; // Move to the next node.
737  }
738 
739  return ++last;
740  }
741 
742  //*************************************************************************
745  //*************************************************************************
746  void unique()
747  {
748  unique(std::equal_to<T>());
749  }
750 
751  //*************************************************************************
754  //*************************************************************************
755  template <typename TIsEqual>
756  void unique(TIsEqual isEqual)
757  {
758  if (empty())
759  {
760  return;
761  }
762 
763  Node* last = &get_head();
764  Node* current = last->next;
765 
766  while (current != &end_node)
767  {
768  // Is this value the same as the last?
769  if (isEqual(data_cast(current)->value, data_cast(last)->value))
770  {
771  remove_node_after(*last);
772  }
773  else
774  {
775  // Move on one.
776  last = current;
777  }
778 
779  current = last->next;
780  }
781  }
782 
783  //*************************************************************************
786  //*************************************************************************
787  void sort()
788  {
789  sort(std::less<T>());
790  }
791 
792  //*************************************************************************
796  //*************************************************************************
797  template <typename TCompare>
798  void sort(TCompare compare)
799  {
800  iterator p_left;
801  iterator p_right;
802  iterator p_node;
803  iterator p_head;
804  iterator p_tail;
805  int list_size = 1;
806  int number_of_merges;
807  int left_size;
808  int right_size;
809 
810  if (is_trivial_list())
811  {
812  return;
813  }
814 
815  while (true)
816  {
817  p_left = begin();
818  p_head = before_begin();
819  p_tail = before_begin();
820 
821  number_of_merges = 0; // Count the number of merges we do in this pass.
822 
823  while (p_left != end())
824  {
825  ++number_of_merges; // There exists a merge to be done.
826  p_right = p_left;
827  left_size = 0;
828 
829  // Step 'list_size' places along from left
830  for (int i = 0; i < list_size; ++i)
831  {
832  ++left_size;
833 
834  ++p_right;
835 
836  if (p_right == end())
837  {
838  break;
839  }
840  }
841 
842  // If right hasn't fallen off end, we have two lists to merge.
843  right_size = list_size;
844 
845  // Now we have two lists. Merge them.
846  while (left_size > 0 || (right_size > 0 && p_right != end()))
847  {
848  // Decide whether the next node of merge comes from left or right.
849  if (left_size == 0)
850  {
851  // Left is empty. The node must come from right.
852  p_node = p_right;
853  ++p_right;
854  --right_size;
855  }
856  else if (right_size == 0 || p_right == end())
857  {
858  // Right is empty. The node must come from left.
859  p_node = p_left;
860  ++p_left;
861  --left_size;
862  }
863  else if (compare(*p_left, *p_right))
864  {
865  // First node of left is lower or same. The node must come from left.
866  p_node = p_left;
867  ++p_left;
868  --left_size;
869  }
870  else
871  {
872  // First node of right is lower. The node must come from right.
873  p_node = p_right;
874  ++p_right;
875  --right_size;
876  }
877 
878  // Add the next node to the merged head.
879  if (p_head == before_begin())
880  {
881  join(*p_head.p_node, *p_node.p_node);
882  p_head = p_node;
883  p_tail = p_node;
884  }
885  else
886  {
887  join(*p_tail.p_node, *p_node.p_node);
888  p_tail = p_node;
889  }
890 
891  join(*p_tail.p_node, end_node);
892  }
893 
894  // Now left has stepped `list_size' places along, and right has too.
895  p_left = p_right;
896  }
897 
898  // If we have done only one merge, we're finished.
899  if (number_of_merges <= 1) // Allow for number_of_merges == 0, the empty head case
900  {
901  return;
902  }
903 
904  // Otherwise repeat, merging lists twice the size
905  list_size *= 2;
906  }
907  }
908 
909  //*************************************************************************
910  // Removes the values specified.
911  //*************************************************************************
912  void remove(parameter_t value)
913  {
914  iterator i_item = begin();
915  iterator i_last_item = before_begin();
916 
917  while (i_item != end())
918  {
919  if (*i_item == value)
920  {
921  i_item = erase_after(i_last_item);
922  }
923  else
924  {
925  ++i_item;
926  ++i_last_item;
927  }
928  }
929  }
930 
931  //*************************************************************************
933  //*************************************************************************
934  template <typename TPredicate>
935  void remove_if(TPredicate predicate)
936  {
937  iterator i_item = begin();
938  iterator i_last_item = before_begin();
939 
940  while (i_item != end())
941  {
942  if (predicate(*i_item))
943  {
944  i_item = erase_after(i_last_item);
945  }
946  else
947  {
948  ++i_item;
949  ++i_last_item;
950  }
951  }
952  }
953 
954  protected:
955 
956  //*************************************************************************
958  //*************************************************************************
959  iforward_list(Data_Node* node_pool, size_t max_size_)
960  : forward_list_base(max_size_),
961  node_pool(node_pool)
962  {
963  initialise();
964  }
965 
968 
969  private:
970 
971  Data_Node* node_pool;
972 
973  //*************************************************************************
975  //*************************************************************************
976  static Data_Node* data_cast(Node* p_node)
977  {
978  return static_cast<Data_Node*>(p_node);
979  }
980 
981  //*************************************************************************
983  //*************************************************************************
984  static Data_Node& data_cast(Node& node)
985  {
986  return static_cast<Data_Node&>(node);
987  }
988 
989  //*************************************************************************
991  //*************************************************************************
992  static const Data_Node* data_cast(const Node* p_node)
993  {
994  return static_cast<const Data_Node*>(p_node);
995  }
996 
997  //*************************************************************************
999  //*************************************************************************
1000  static const Data_Node& data_cast(const Node& node)
1001  {
1002  return static_cast<const Data_Node&>(node);
1003  }
1004 
1005  //*************************************************************************
1007  //*************************************************************************
1008  void join(Node& left, Node& right)
1009  {
1010  left.next = &static_cast<Data_Node&>(right);
1011  }
1012 
1013  //*************************************************************************
1015  //*************************************************************************
1016  void join(Data_Node& left, Data_Node& right)
1017  {
1018  left.next = &right;
1019  }
1020 
1021  //*************************************************************************
1023  //*************************************************************************
1024  bool is_trivial_list() const
1025  {
1026  return (size() < 2);
1027  }
1028 
1029  //*************************************************************************
1031  //*************************************************************************
1032  void find_next_free()
1033  {
1034  while (next_free != MAX_SIZE)
1035  {
1036  if (node_pool[next_free].is_free())
1037  {
1038  return;
1039  }
1040  else
1041  {
1042  ++next_free;
1043  }
1044  }
1045  }
1046 
1047  //*************************************************************************
1049  //*************************************************************************
1050  void insert_node_after(Node& position, Node& node)
1051  {
1052  // Connect to the forward_list.
1053  join(node, *position.next);
1054  join(position, node);
1055 
1056  // One more.
1057  ++count;
1058 
1059  // Update the position of the next free node in the pool.
1060  find_next_free();
1061  }
1062 
1063  //*************************************************************************
1065  //*************************************************************************
1066  void remove_node_after(Node& node)
1067  {
1068  // The node to erase.
1069  Node* p_node = node.next;
1070 
1071  // One less.
1072  --count;
1073 
1074  // Disconnect the node from the forward_list.
1075  join(node, *p_node->next);
1076  p_node->mark_as_free();
1077 
1078  // Update the position of the next free node in the pool.
1079  size_t new_free = std::distance(&node_pool[0], static_cast<Data_Node*>(p_node));
1080  next_free = std::min(next_free, new_free);
1081  }
1082 
1083  //*************************************************************************
1085  //*************************************************************************
1086  Node& get_head()
1087  {
1088  return static_cast<Data_Node&>(*start_node.next);
1089  }
1090 
1091  //*************************************************************************
1093  //*************************************************************************
1094  const Node& get_head() const
1095  {
1096  return *start_node.next;
1097  }
1098 
1099  //*************************************************************************
1101  //*************************************************************************
1102  void initialise()
1103  {
1104  // Reset the node pool.
1105  for (size_t i = 0; i < max_size(); ++i)
1106  {
1107  node_pool[i].mark_as_free();
1108  }
1109 
1110  next_free = 0;
1111  count = 0;
1112  join(start_node, end_node);
1113  join(end_node, start_node);
1114  }
1115  };
1116 }
1117 
1118 //*************************************************************************
1123 //*************************************************************************
1124 template <typename T>
1126 {
1127  return (lhs.size() == rhs.size()) &&
1128  std::equal(lhs.begin(), lhs.end(), rhs.begin());
1129 }
1130 
1131 //*************************************************************************
1136 //*************************************************************************
1137 template <typename T>
1139 {
1140  return !(lhs == rhs);
1141 }
1142 
1143 //*************************************************************************
1149 //*************************************************************************
1150 template <typename T>
1151 bool operator <(const etl::iforward_list<T>& lhs, const etl::iforward_list<T>& rhs)
1152 {
1153  return std::lexicographical_compare(lhs.begin(),
1154  lhs.end(),
1155  rhs.begin(),
1156  rhs.end());
1157 }
1158 
1159 //*************************************************************************
1165 //*************************************************************************
1166 template <typename T>
1168 {
1169  return std::lexicographical_compare(lhs.begin(),
1170  lhs.end(),
1171  rhs.begin(),
1172  rhs.end(),
1173  std::greater<T>());
1174 }
1175 
1176 //*************************************************************************
1182 //*************************************************************************
1183 template <typename T>
1184 bool operator <=(const etl::iforward_list<T>& lhs, const etl::iforward_list<T>& rhs)
1185 {
1186  return !operator >(lhs, rhs);
1187 }
1188 
1189 //*************************************************************************
1195 //*************************************************************************
1196 template <typename T>
1198 {
1199  return !operator <(lhs, rhs);
1200 }
1201 
1202 #if WIN32
1203 #define min(a,b) (((a) < (b)) ? (a) : (b))
1204 #endif
1205 
1206 #endif
void push_front()
Adds a node to the front of the forward_list so a new value can be assigned to front().
Definition: iforward_list.h:473
bool full() const
Checks to see if the forward_list is full.
Definition: forward_list_base.h:120
bool operator==(const etl::iforward_list< T > &lhs, const etl::iforward_list< T > &rhs)
Definition: iforward_list.h:1125
iterator erase_after(iterator position)
Erases the value at the specified position.
Definition: iforward_list.h:699
const_iterator end() const
Gets the end of the forward_list.
Definition: iforward_list.h:328
const_iterator cbegin() const
Gets the beginning of the forward_list.
Definition: iforward_list.h:312
iforward_list(Data_Node *node_pool, size_t max_size_)
Constructor.
Definition: iforward_list.h:959
bitset< N > operator&(const bitset< N > &lhs, const bitset< N > &rhs)
Definition: bitset.h:1154
void unique(TIsEqual isEqual)
Definition: iforward_list.h:756
Node start_node
The node that acts as the forward_list start.
Definition: iforward_list.h:966
void sort(TCompare compare)
Definition: iforward_list.h:798
iterator erase_after(iterator first, iterator last)
Erases a range of elements.
Definition: iforward_list.h:713
size_t size_type
The type used for determining the size of forward_list.
Definition: forward_list_base.h:91
size_type next_free
The index of the next free node.
Definition: forward_list_base.h:147
Determine how to pass parameters.
Definition: parameter_type.h:40
void resize(size_t n, T value)
Definition: iforward_list.h:541
iterator insert_after(iterator position, parameter_t value)
Inserts a value to the forward_list after the specified position.
Definition: iforward_list.h:612
iterator begin()
Gets the beginning of the forward_list.
Definition: iforward_list.h:280
Definition: forward_list_base.h:87
bool operator>(const etl::iforward_list< T > &lhs, const etl::iforward_list< T > &rhs)
Definition: iforward_list.h:1167
iforward_list & operator=(const iforward_list &rhs)
Assignment operator.
Definition: iforward_list.h:344
const_iterator cend() const
Gets the end of the forward_list.
Definition: iforward_list.h:336
void unique()
Definition: iforward_list.h:746
void insert_after(iterator position, TIterator first, TIterator last)
Inserts a range of values to the forward_list after the specified position.
Definition: iforward_list.h:669
void push_front(parameter_t value)
Pushes a value to the front of the forward_list.
Definition: iforward_list.h:496
size_type size() const
Gets the size of the forward_list.
Definition: forward_list_base.h:96
Definition: algorithm.h:43
void assign(TIterator first, TIterator last)
If ETL_THROW_EXCEPTIONS & _DEBUG are defined throws forward_list_iterator if the iterators are revers...
Definition: iforward_list.h:381
bool operator>=(const etl::iforward_list< T > &lhs, const etl::iforward_list< T > &rhs)
Definition: iforward_list.h:1197
The data node element in the forward_list.
Definition: iforward_list.h:97
iterator.
Definition: iforward_list.h:107
void resize(size_t n)
Resizes the forward_list.
Definition: iforward_list.h:531
void clear()
Clears the forward_list.
Definition: iforward_list.h:354
iterator before_begin()
Gets before the beginning of the forward_list.
Definition: iforward_list.h:296
void assign(size_t n, parameter_t value)
Assigns 'n' copies of a value to the forward_list.
Definition: iforward_list.h:427
void reverse()
Reverses the forward_list.
Definition: iforward_list.h:584
const_iterator before_begin() const
Gets before the beginning of the forward_list.
Definition: iforward_list.h:304
size_type max_size() const
Gets the maximum possible size of the forward_list.
Definition: forward_list_base.h:104
const_reference front() const
Gets a const reference to the first element.
Definition: iforward_list.h:370
bool operator<(const etl::iforward_list< T > &lhs, const etl::iforward_list< T > &rhs)
Definition: iforward_list.h:1151
iterator end()
Gets the end of the forward_list.
Definition: iforward_list.h:320
const_iterator begin() const
Gets the beginning of the forward_list.
Definition: iforward_list.h:288
TIterator next(TIterator iterator, ptrdiff_t n=1)
Definition: container.h:245
bool empty() const
Checks to see if the forward_list is empty.
Definition: forward_list_base.h:112
void sort()
Definition: iforward_list.h:787
Definition: type_traits.h:226
reference front()
Gets a reference to the first element.
Definition: iforward_list.h:362
static void error(const exception &e)
Definition: error_handler.cpp:50
Node end_node
The node that acts as the forward_list end.
Definition: iforward_list.h:967
const size_type MAX_SIZE
The maximum size of the forward_list.
Definition: forward_list_base.h:149
void remove_if(TPredicate predicate)
Removes according to a predicate.
Definition: iforward_list.h:935
bool operator!=(const etl::iforward_list< T > &lhs, const etl::iforward_list< T > &rhs)
Definition: iforward_list.h:1138
void pop_front()
Removes a value from the front of the forward_list.
Definition: iforward_list.h:520
Definition: forward_list_base.h:59
void insert_after(iterator position, size_t n, parameter_t value)
Inserts 'n' copies of a value to the forward_list after the specified position.
Definition: iforward_list.h:640
const_iterator
Definition: iforward_list.h:195
size_type count
The number of the used nodes.
Definition: forward_list_base.h:148
Definition: iforward_list.h:74
Definition: iforward_list.h:54