Evo C++ Library v0.5.1
iter.h
Go to the documentation of this file.
1 // Evo C++ Library
2 /* Copyright 2019 Justin Crowell
3 Distributed under the BSD 2-Clause License -- see included file LICENSE.txt for details.
4 */
6 
7 #pragma once
8 #ifndef INCL_evo_impl_iter_h
9 #define INCL_evo_impl_iter_h
10 
11 #include "../type.h"
12 
13 namespace evo {
16 
18 
24 };
25 
31 };
32 
34 
42 template<class T>
43 class IteratorBase : public SafeBool< IteratorBase<T> > {
44 public:
45  typedef typename T::Size Size;
46  typedef typename T::IterKey Key;
47  typedef typename StaticIf< IsConst<T>::value,
48  const typename T::IterItem,
49  typename T::IterItem
50  >::Type Item;
51 
53 
56  typedef typename StaticIf<IsConst<T>::value,Mutable,Const>::Type ToggleConst;
57 
58  typedef T Target;
59 
63  explicit IteratorBase(T& obj) : obj_(&obj), end_(true), data_(NULL)
64  { init(); }
65 
71  IteratorBase(T& obj, const Key& key, Item* data) : obj_(&obj), end_(false), key_(key), data_(data)
72  { init(); }
73 
77  IteratorBase(const IterBaseType& src)
78  { memcpy(this, &src, sizeof(src)); init(); }
79 
84  IterBaseType& operator=(const IterBaseType& src)
85  { memcpy(this, &src, sizeof(src)); init(); return *this; }
86 
94  IterBaseType& operator=(const ToggleConst& src) {
95  STATIC_ASSERT(IsConst<T>::value, ERROR_cannot_assign_const_iterator_to_mutable_iterator);
96  operator=((IterBaseType&)src);
97  return *this;
98  }
99 
104  IterBaseType& operator=(T& obj)
105  { obj_ = &obj; end_ = true; data_ = NULL; return *this; }
106 
111  IterBaseType& operator=(IteratorPos pos) {
112  EVO_PARAM_UNUSED(pos);
113  end_ = true; data_ = NULL; return *this;
114  }
115 
121  Item& operator*()
122  { return *data_; }
123 
129  Item* operator->()
130  { return data_; }
131 
135  bool operator!() const
136  { return end_; }
137 
142  bool operator==(const IterBaseType& iter) const
143  { return (this == &iter || (end_ == iter.end_ && data_ == iter.data_)); }
144 
149  bool operator!=(const IterBaseType& iter) const
150  { return (this != &iter && (end_ != iter.end_ || data_ != iter.data_)); }
151 
156  template<typename T_>
157  bool operator==(const IteratorBase<T_>& oth) const
158  { return IterBaseType::operator==((const IterBaseType&)oth); }
159 
164  template<typename T_>
165  bool operator!=(const IteratorBase<T_>& oth) const
166  { return IterBaseType::operator!=((const IterBaseType&)oth); }
167 
170  T& getParent() const
171  { return *obj_; }
172 
174  bool getEnd() const
175  { return end_; }
176 
178  const Key& getKey() const
179  { return key_; }
180 
182  Key& getKey()
183  { return key_; }
184 
186  void set(const Key& key, const Item* data) {
187  key_ = key;
188  data_ = (Item*)data;
189  end_ = (data_ == NULL);
190  }
191 
193  void setData(const Item* item)
194  { data_ = (Item*)item; }
198  static const IterBaseType& end()
199  { static const IterBaseType End; return End; }
200 
201 protected:
202  T* obj_;
203  bool end_;
204  Key key_;
205  Item* data_;
206 
208  explicit IteratorBase() : obj_(NULL), end_(true), data_(NULL)
209  { }
210 
215  explicit IteratorBase(T* obj) : obj_(obj)
216  { init(); }
217 
218 private:
219  void init() {
220  if (obj_ != NULL && !IsConst<T>::value)
221  // Only called with mutable iterator
222  ((typename RemoveConst<T>::Type*)obj_)->iterInitMutable();
223  }
224 };
225 
227 
339 template<class T>
340 class IteratorFw : public IteratorBase<T> {
341 protected:
342  using IteratorBase<T>::obj_;
343  using IteratorBase<T>::end_;
344  using IteratorBase<T>::key_;
346 
347 public:
348  typedef typename IteratorBase<T>::Size Size;
349  typedef typename IteratorBase<T>::Key Key;
350  typedef typename IteratorBase<T>::Item Item;
351 
356 
357  typedef typename StaticIf<IsConst<T>::value,Mutable,Const>::Type ToggleConst;
358 
361  { }
362 
366  explicit IteratorFw(T& obj) : IteratorBase<T>(obj)
367  { first(); }
368 
373  explicit IteratorFw(T& obj, IteratorPos pos) : IteratorBase<T>(&obj) {
374  switch (pos) {
375  case iterFIRST: first(); break;
376  default: end_ = true; data_ = NULL; break;
377  };
378  }
379 
385  IteratorFw(T& obj, const Key& key, Item* data) : IteratorBase<T>(obj, key, data)
386  { }
387 
391  IteratorFw(const IterType& src) : IteratorBase<T>(src)
392  { }
393 
395  IteratorFw(const IterBaseType& src) : IteratorBase<T>(src)
396  { }
397 
399  IterType& operator=(const IterType& src)
400  { IterBaseType::operator=(src); return *this; }
401 
403  IterType& operator=(const IterBaseType& src)
404  { IterBaseType::operator=(src); return *this; }
405 
407  IterType& operator=(const ToggleConst& src) {
408  STATIC_ASSERT(IsConst<T>::value, ERROR_cannot_assign_const_iterator_to_mutable_iterator);
409  IterBaseType::operator=((IterType&)src);
410  return *this;
411  }
412 
414  IterType& operator=(const typename IterBaseType::ToggleConst& src) {
415  STATIC_ASSERT(IsConst<T>::value, ERROR_cannot_assign_const_iterator_to_mutable_iterator);
416  IterBaseType::operator=((IterType&)src);
417  return *this;
418  }
419 
424  IterType& operator=(T& obj)
425  { IterBaseType::operator=(obj); first(); return *this; }
426 
431  IterType& operator=(IteratorPos pos) {
432  switch (pos) {
433  case iterFIRST: first(); break;
434  default: end_ = true; data_ = NULL; break;
435  };
436  return *this;
437  }
438 
442  IterType& operator++()
443  { next(); return *this; }
444 
448  IterType operator++(int)
449  { IterType tmp(*this); next(); return tmp; }
450 
451  // Inherited overloads
454 
455 protected:
459  explicit IteratorFw(T* obj) : IteratorBase<T>(obj)
460  { }
461 
465  bool first() {
466  data_ = (Item*)obj_->iterFirst(key_);
467  return end_ = (data_ == NULL);
468  }
469 
473  bool next() {
474  if (end_)
475  return false;
476  data_ = (Item*)obj_->iterNext(key_);
477  if (data_ == NULL)
478  end_ = true;
479  return !end_;
480  }
481 };
482 
484 
610 template<class T>
611 class IteratorBi : public IteratorFw<T> {
612 protected:
613  using IteratorBase<T>::obj_;
614  using IteratorBase<T>::end_;
615  using IteratorBase<T>::key_;
617 
618  using IteratorFw<T>::first;
619 
620 public:
621  typedef typename IteratorBase<T>::Size Size;
622  typedef typename IteratorBase<T>::Key Key;
623  typedef typename IteratorBase<T>::Item Item;
624 
629 
630  typedef typename StaticIf<IsConst<T>::value,Mutable,Const>::Type ToggleConst;
631 
634  { }
635 
639  explicit IteratorBi(T& obj) : IteratorFw<T>(obj)
640  { }
641 
646  explicit IteratorBi(T& obj, IteratorPos pos) : IteratorFw<T>(&obj) {
647  switch (pos) {
648  case iterFIRST: first(); break;
649  case iterLAST: last(); break;
650  default: end_ = true; data_ = NULL; break;
651  };
652  }
653 
659  IteratorBi(T& obj, const Key& key, Item* data) : IteratorFw<T>(obj, key, data)
660  { }
661 
665  IteratorBi(const IterType& src) : IteratorFw<T>(src)
666  { }
667 
669  IteratorBi(const IterBaseType& src) : IteratorFw<T>(src)
670  { }
671 
673  IterType& operator=(const IterType& src)
674  { IterBaseType::operator=(src); return *this; }
675 
677  IterType& operator=(const IterBaseType& src)
678  { IterBaseType::operator=(src); return *this; }
679 
681  IterType& operator=(const ToggleConst& src) {
682  STATIC_ASSERT(IsConst<T>::value, ERROR_cannot_assign_const_iterator_to_mutable_iterator);
683  IterBaseType::operator=((IterType&)src);
684  return *this;
685  }
686 
688  IterType& operator=(const typename IterBaseType::ToggleConst& src) {
689  STATIC_ASSERT(IsConst<T>::value, ERROR_cannot_assign_const_iterator_to_mutable_iterator);
690  IterBaseType::operator=((IterType&)src);
691  return *this;
692  }
693 
695  IterType& operator=(T& obj)
696  { IterBaseType::operator=(obj); first(); return *this; }
697 
702  IterType& operator=(IteratorPos pos) {
703  switch (pos) {
704  case iterFIRST: first(); break;
705  case iterLAST: last(); break;
706  default: end_ = true; data_ = NULL; break;
707  };
708  return *this;
709  }
710 
714  IterType& operator--()
715  { prev(); return *this; }
716 
720  IterType operator--(int)
721  { IterType tmp(*this); prev(); return tmp; }
722 
723  // Inherited overloads
724  using IteratorFw<T>::operator==;
725  using IteratorFw<T>::operator!=;
726 
727 protected:
732  explicit IteratorBi(T* obj) : IteratorFw<T>(obj)
733  { }
734 
738  bool last() {
739  data_ = (Item*)obj_->iterLast(key_);
740  return end_ = (data_ == NULL);
741  }
742 
746  bool prev() {
747  if (end_)
748  return false;
749  data_ = (Item*)obj_->iterPrev(key_);
750  if (data_ == NULL)
751  end_ = true;
752  return !end_;
753  }
754 };
755 
757 
903 template<class T>
904 class IteratorRa : public IteratorBi<T> {
905 protected:
906  using IteratorBase<T>::obj_;
907  using IteratorBase<T>::end_;
908  using IteratorBase<T>::key_;
910 
911  using IteratorFw<T>::first;
912 
913 public:
914  typedef typename IteratorBase<T>::Size Size;
915  typedef typename IteratorBase<T>::Key Key;
916  typedef typename IteratorBase<T>::Item Item;
917 
922 
923  typedef typename StaticIf<IsConst<T>::value,Mutable,Const>::Type ToggleConst;
924 
927  { }
928 
932  explicit IteratorRa(T& obj) : IteratorBi<T>(obj)
933  { }
934 
939  explicit IteratorRa(T& obj, IteratorPos pos) : IteratorBi<T>(obj, pos)
940  { }
941 
946  IteratorRa(T& obj, Key num) : IteratorBi<T>(&obj) {
947  data_ = (Item*)obj_->iterSet(num);
948  end_ = (data_ == NULL);
949  key_ = num;
950  }
951 
957  IteratorRa(T& obj, const Key& key, Item* data) : IteratorBi<T>(obj, key, data)
958  { }
959 
963  IteratorRa(const IterType& src) : IteratorBi<T>(src)
964  { }
965 
967  IteratorRa(const IterBaseType& src) : IteratorBi<T>(src)
968  { }
969 
971  IterType& operator=(const IterType& src)
972  { IterBaseType::operator=(src); return *this; }
973 
975  IterType& operator=(const IterBaseType& src)
976  { IterBaseType::operator=(src); return *this; }
977 
979  IterType& operator=(const ToggleConst& src) {
980  STATIC_ASSERT(IsConst<T>::value, ERROR_cannot_assign_const_iterator_to_mutable_iterator);
981  IterBaseType::operator=((IterType&)src);
982  return *this;
983  }
984 
986  IterType& operator=(const typename IterBaseType::ToggleConst& src) {
987  STATIC_ASSERT(IsConst<T>::value, ERROR_cannot_assign_const_iterator_to_mutable_iterator);
988  IterBaseType::operator=((IterType&)src);
989  return *this;
990  }
991 
993  IterType& operator=(T& obj)
994  { IterBaseType::operator=(obj); first(); return *this; }
995 
997  IterType& operator=(IteratorPos pos)
998  { IteratorBi<T>::operator=(pos); return *this; }
999 
1004  IterType& operator=(Key num) {
1005  data_ = (Item*)obj_->iterSet(num);
1006  end_ = (data_ == NULL);
1007  key_ = num;
1008  return *this;
1009  }
1010 
1015  IterType& operator+=(Size count)
1016  { next(count); return *this; }
1017 
1022  IterType& operator-=(Size count)
1023  { prev(count); return *this; }
1024 
1031  IterType operator+(Size count) const
1032  { IterType tmp(*this); tmp.next(count); return tmp; }
1033 
1040  IterType operator-(Size count) const
1041  { IterType tmp(*this); tmp.prev(count); return tmp; }
1042 
1047  int compare(const IterBaseType& iter) const {
1048  if (iter.getEnd())
1049  return (end_ ? 0 : -1);
1050  else if (end_)
1051  return 1;
1052  else if (key_ == iter.getKey())
1053  return 0;
1054  else
1055  return (key_ < iter.getKey() ? -1 : 1);
1056  }
1057 
1062  int compare(Key num) const {
1063  if (num == END)
1064  return (end_ ? 0 : -1);
1065  else if (end_)
1066  return 1;
1067  else if (key_ == num)
1068  return 0;
1069  else
1070  return (key_ < num ? -1 : 1);
1071  }
1072 
1077  bool operator<(const IterBaseType& iter) const
1078  { return (compare(iter) < 0); }
1079 
1084  bool operator<(Key num) const
1085  { return (compare(num) < 0); }
1086 
1091  bool operator<=(const IterBaseType& iter) const
1092  { return (compare(iter) <= 0); }
1093 
1098  bool operator<=(Key num) const
1099  { return (compare(num) <= 0); }
1100 
1105  bool operator>(const IterBaseType& iter) const
1106  { return (compare(iter) > 0); }
1107 
1112  bool operator>(Key num) const
1113  { return (compare(num) > 0); }
1114 
1119  bool operator>=(const IterBaseType& iter) const
1120  { return (compare(iter) >= 0); }
1121 
1126  bool operator>=(Key num) const
1127  { return (compare(num) >= 0); }
1128 
1129  // Inherited overloads
1130  using IteratorBi<T>::operator==;
1131  using IteratorBi<T>::operator!=;
1132 
1137  bool operator==(Key num) const
1138  { return (compare(num) == 0); }
1139 
1144  bool operator!=(Key num) const
1145  { return (compare(num) != 0); }
1146 
1150  Size count() const
1151  { return obj_->iterCount(); }
1152 
1156  Key index() const
1157  { return (end_ ? Key(END) : key_); }
1158 
1159 protected:
1164  bool next(Size count) {
1165  if (end_)
1166  return false;
1167  data_ = (Item*)obj_->iterNext(count, key_);
1168  if (data_ == NULL)
1169  end_ = true;
1170  return !end_;
1171  }
1172 
1177  bool prev(Size count) {
1178  if (end_)
1179  return false;
1180  data_ = (Item*)obj_->iterPrev(count, key_);
1181  if (data_ == NULL)
1182  end_ = true;
1183  return !end_;
1184  }
1185 };
1186 
1188 
1226 template<class T, int F, int L>
1227 class EnumIterator : public SafeBool< EnumIterator<T,F,L> > {
1228 public:
1230  typedef T EnumType;
1231  static const T FIRST = (T)F;
1232  static const T LAST = (T)L;
1233 
1235  EnumIterator() : value_(FIRST), end_(false) {
1236  }
1237 
1241  EnumIterator(const This& src) : value_(src.value_), end_(src.end_) {
1242  }
1243 
1247  EnumIterator(EnumType value) : value_(value), end_(false) {
1248  }
1249 
1254  setpos(pos);
1255  }
1256 
1261  This& operator=(const This& src) {
1262  value_ = src.value_;
1263  end_ = src.end_;
1264  return *this;
1265  }
1266 
1271  This& operator=(EnumType value) {
1272  value_ = value;
1273  end_ = false;
1274  return *this;
1275  }
1276 
1281  This& operator=(IteratorPos pos) {
1282  setpos(pos);
1283  return *this;
1284  }
1285 
1289  bool operator!() const
1290  { return end_; }
1291 
1295  EnumType operator*() const
1296  { return value_; }
1297 
1302  bool operator==(const This& oth) const
1303  { return (end_ == oth.end_ && value_ == oth.value_); }
1304 
1309  bool operator!=(const This& oth) const
1310  { return (end_ != oth.end_ || value_ != oth.value_); }
1311 
1315  This& operator++() {
1316  next();
1317  return *this;
1318  }
1319 
1323  This operator++(int) {
1324  This result(*this);
1325  next();
1326  return result;
1327  }
1328 
1332  This& operator--() {
1333  prev();
1334  return *this;
1335  }
1336 
1340  This operator--(int) {
1341  This result(*this);
1342  prev();
1343  return result;
1344  }
1345 
1349  EnumType value() const
1350  { return value_; }
1351 
1355  int value_num(int endvalue=0) const {
1356  if (end_)
1357  return endvalue;
1358  return (int)value_;
1359  }
1360 
1361 protected:
1362  EnumType value_;
1363  bool end_;
1364 
1365  void setpos(IteratorPos pos) {
1366  switch (pos) {
1367  case iterFIRST:
1368  value_ = FIRST;
1369  end_ = false;
1370  break;
1371  case iterLAST:
1372  value_ = LAST;
1373  end_ = false;
1374  break;
1375  default:
1376  value_ = LAST;
1377  end_ = true;
1378  break;
1379  }
1380  }
1381 
1382  void prev() {
1383  if (!end_) {
1384  if (value_ <= FIRST)
1385  end_ = true;
1386  else
1387  value_ = (EnumType)((int)value_ - 1);
1388  }
1389  }
1390 
1391  void next() {
1392  if (!end_) {
1393  if (value_ >= LAST)
1394  end_ = true;
1395  else
1396  value_ = (EnumType)((int)value_ + 1);
1397  }
1398  }
1399 };
1400 
1402 
1403 }
1404 #endif
IterType & operator=(IteratorPos pos)
Assignment operator to set position.
Definition: iter.h:431
IteratorRa()
Constructor.
Definition: iter.h:926
T Target
Iterator target type.
Definition: iter.h:58
IteratorBase()
Constructor (used internally).
Definition: iter.h:208
Item * data_
Item pointer.
Definition: iter.h:205
This & operator=(EnumType value)
Assignment operator to set at explicit enum value.
Definition: iter.h:1271
IteratorRa< const T > Const
Random access const iterator type.
Definition: iter.h:918
IterType & operator-=(Size count)
In-place subtraction (multi decrement) operator.
Definition: iter.h:1022
IteratorRa< typename RemoveConst< T >::Type > Mutable
Random access mutable iterator type.
Definition: iter.h:919
bool operator!() const
Check whether iterator is at end.
Definition: iter.h:1289
bool operator<(Key num) const
Less-than operator.
Definition: iter.h:1084
IteratorBase< T >::Key Key
Iterator key type.
Definition: iter.h:915
IterType & operator=(IteratorPos pos)
Assignment operator to set position.
Definition: iter.h:997
IteratorBi(T &obj)
Constructor.
Definition: iter.h:639
IterBaseType & operator=(const IterBaseType &src)
Copy/Assignment operator to copy from source iterator.
Definition: iter.h:84
StaticIf< IsConst< T >::value, Mutable, Const >::Type ToggleConst
Used for converting between Const/Mutable iterators.
Definition: iter.h:923
This & operator--()
Pre decrement operator, moves to previous enum value or end.
Definition: iter.h:1332
Static conditional type.
Definition: meta.h:134
IterType & operator=(const typename IterBaseType::ToggleConst &src)
Assignment operator to copy from source iterator.
Definition: iter.h:414
IteratorBase< T > IterBaseType
Iterator base type for parameter passing.
Definition: iter.h:921
StaticIf< IsConst< T >::value, const typename T::IterItem, typename T::IterItem >::Type Item
Iterator item type.
Definition: iter.h:50
T * obj_
Container object pointer.
Definition: iter.h:202
IteratorBi(T &obj, IteratorPos pos)
Constructor setting position.
Definition: iter.h:646
bool next(Size count)
Go to next item, skipping given count (used internally).
Definition: iter.h:1164
bool operator==(const IterBaseType &iter) const
Equality operator.
Definition: iter.h:142
IteratorBi(const IterType &src)
Copy constructor.
Definition: iter.h:665
bool operator>(const IterBaseType &iter) const
Greater-than operator.
Definition: iter.h:1105
This & operator++()
Pre increment operator, moves to next enum value or end.
Definition: iter.h:1315
This & operator=(const This &src)
Assignment operator.
Definition: iter.h:1261
IteratorBi(T *obj)
Constructor (used internally).
Definition: iter.h:732
IteratorBi< T > IterType
Iterator type.
Definition: iter.h:627
IteratorBase< T > IterBaseType
Iterator base type for parameter passing.
Definition: iter.h:628
T first(T val1, T val2)
Definition: alg.h:85
IterType & operator=(const IterType &src)
Copy/Assignment operator to copy from source iterator.
Definition: iter.h:971
Random access iterator.
Definition: iter.h:904
This & operator=(IteratorPos pos)
Assignment operator to set at given position.
Definition: iter.h:1281
IterType & operator++()
Pre increment operator.
Definition: iter.h:442
IteratorBi()
Constructor.
Definition: iter.h:633
bool operator!() const
Check whether iterator is at end (not valid).
Definition: iter.h:135
This operator--(int)
Post decrement operator, moves to previous enum value or end.
Definition: iter.h:1340
IterType & operator=(const ToggleConst &src)
Assignment operator to copy from source iterator.
Definition: iter.h:979
bool operator!=(const IteratorBase< T_ > &oth) const
Check inequality with another iterator.
Definition: iter.h:165
IteratorPos
Iterator position value.
Definition: iter.h:20
bool operator!=(Key num) const
Inequality operator.
Definition: iter.h:1144
int compare(const IterBaseType &iter) const
Compare to another iterator.
Definition: iter.h:1047
IterType operator--(int)
Post decrement operator.
Definition: iter.h:720
IteratorFw(T &obj, const Key &key, Item *data)
Constructor.
Definition: iter.h:385
bool operator>(Key num) const
Greater-than operator.
Definition: iter.h:1112
T::IterKey Key
Iterator key type.
Definition: iter.h:46
IterType & operator=(const IterBaseType &src)
Copy/Assignment operator to copy from source iterator.
Definition: iter.h:403
IteratorBase(T &obj, const Key &key, Item *data)
Constructor.
Definition: iter.h:71
bool operator<=(Key num) const
Less-than-or-equal operator.
Definition: iter.h:1098
bool first()
Go to first item (used internally).
Definition: iter.h:465
IteratorBase(T &obj)
Constructor.
Definition: iter.h:63
StaticIf< IsConst< T >::value, Mutable, Const >::Type ToggleConst
Used for converting between Const/Mutable iterators.
Definition: iter.h:56
IterBaseType & operator=(IteratorPos pos)
Assignment operator to set position.
Definition: iter.h:111
EnumType value_
Definition: iter.h:1362
bool end_
End flag.
Definition: iter.h:203
bool operator==(const IteratorBase< T_ > &oth) const
Check equality with another iterator.
Definition: iter.h:157
bool prev(Size count)
Go to previous item, skipping given count (used internally).
Definition: iter.h:1177
IteratorBase(const IterBaseType &src)
Copy constructor.
Definition: iter.h:77
EnumIterator()
Constructor, sets to first enum value.
Definition: iter.h:1235
IterType & operator+=(Size count)
In-place addition (multi increment) operator.
Definition: iter.h:1015
Last item iterator position.
Definition: iter.h:22
T::Size Size
Size type to use.
Definition: iter.h:45
IterType & operator=(Key num)
Assignment operator for random access position index.
Definition: iter.h:1004
Check if type is const.
Definition: meta.h:215
IterType & operator--()
Pre decrement operator.
Definition: iter.h:714
IterBaseType & operator=(const ToggleConst &src)
Assignment operator to copy from source iterator.
Definition: iter.h:94
IteratorBase< T > IterBaseType
Iterator base type for parameter passing.
Definition: iter.h:52
T Type
Translated type.
Definition: meta.h:331
bool next()
Go to next item (used internally).
Definition: iter.h:473
IteratorFw(const IterBaseType &src)
Copy constructor.
Definition: iter.h:395
IteratorBase< T > IterBaseType
Iterator base type for parameter passing.
Definition: iter.h:355
Safe bool base class.
Definition: type.h:73
IteratorBase< T >::Item Item
Iterator item type.
Definition: iter.h:350
IterType & operator=(const typename IterBaseType::ToggleConst &src)
Assignment operator to copy from source iterator.
Definition: iter.h:688
First item iterator position.
Definition: iter.h:21
Key key_
Iterator key.
Definition: iter.h:204
Size count() const
Get container item count.
Definition: iter.h:1150
Bidirectional iterator.
Definition: iter.h:611
IteratorRa(T &obj, Key num)
Constructor setting position.
Definition: iter.h:946
void setpos(IteratorPos pos)
Definition: iter.h:1365
Iterator template for sequential enum values.
Definition: iter.h:1227
void prev()
Definition: iter.h:1382
T EnumType
Definition: iter.h:1230
static const EndT END
Special integer value for indicating end of items or no item.
Definition: type.h:1846
bool operator<=(const IterBaseType &iter) const
Less-than-or-equal operator.
Definition: iter.h:1091
EnumIterator< T, F, L > This
Definition: iter.h:1229
IterType operator++(int)
Post increment operator.
Definition: iter.h:448
IterType & operator=(const IterType &src)
Copy/Assignment operator to copy from source iterator.
Definition: iter.h:673
bool last()
Go to last item.
Definition: iter.h:738
Forward iterator.
Definition: iter.h:340
IterType & operator=(const IterBaseType &src)
Copy/Assignment operator to copy from source iterator.
Definition: iter.h:975
IteratorFw< typename RemoveConst< T >::Type > Mutable
Forward mutable iterator type.
Definition: iter.h:353
bool operator==(const This &oth) const
Equality operator to compare with another iterator to same enum.
Definition: iter.h:1302
IteratorDir
Iterator direction value.
Definition: iter.h:27
IteratorBi(const IterBaseType &src)
Copy constructor.
Definition: iter.h:669
int compare(Key num) const
Compare to a position index.
Definition: iter.h:1062
Item * operator->()
Dereference iterator to access data member.
Definition: iter.h:129
IteratorBase< typename RemoveConst< T >::Type > Mutable
Mutable iterator type.
Definition: iter.h:55
bool operator!=(const IterBaseType &iter) const
Inequality operator.
Definition: iter.h:149
IterType & operator=(T &obj)
Assignment operator.
Definition: iter.h:695
IterType & operator=(const ToggleConst &src)
Assignment operator to copy from source iterator.
Definition: iter.h:681
EnumIterator(const This &src)
Copy constructor.
Definition: iter.h:1241
void next()
Definition: iter.h:1391
Reverse iterator direction.
Definition: iter.h:30
IteratorBase< const T > Const
Const iterator type.
Definition: iter.h:54
IterType & operator=(const IterType &src)
Copy/Assignment operator to copy from source iterator.
Definition: iter.h:399
Evo C++ Library namespace.
Definition: alg.h:11
No iterator direction.
Definition: iter.h:28
EnumIterator(IteratorPos pos)
Constructor to start at given position.
Definition: iter.h:1253
IteratorFw(const IterType &src)
Copy constructor.
Definition: iter.h:391
IterType operator+(Size count) const
Addition (multi increment) operator.
Definition: iter.h:1031
bool operator!=(const This &oth) const
Inequality operator to compare with another iterator to same enum.
Definition: iter.h:1309
bool prev()
Go to previous item.
Definition: iter.h:746
EnumIterator(EnumType value)
Constructor to start at explicit enum value.
Definition: iter.h:1247
IteratorRa(const IterType &src)
Copy constructor.
Definition: iter.h:963
IteratorRa(T &obj)
Constructor.
Definition: iter.h:932
IteratorRa< T > IterType
Iterator type.
Definition: iter.h:920
IteratorBase< T >::Key Key
Iterator key type.
Definition: iter.h:622
IteratorRa(T &obj, IteratorPos pos)
Constructor setting position.
Definition: iter.h:939
EnumType operator*() const
Dereference iterator to get current enum value.
Definition: iter.h:1295
StaticIf< IsConst< T >::value, Mutable, Const >::Type ToggleConst
Used for converting between Const/Mutable iterators.
Definition: iter.h:630
IteratorFw()
Constructor.
Definition: iter.h:360
End iterator position.
Definition: iter.h:23
IteratorBase< T >::Item Item
Iterator item type.
Definition: iter.h:916
Base iterator (used internally).
Definition: iter.h:43
bool operator==(Key num) const
Equality operator.
Definition: iter.h:1137
bool operator<(const IterBaseType &iter) const
Less-than operator.
Definition: iter.h:1077
bool operator>=(const IterBaseType &iter) const
Greater-than-or-equal operator.
Definition: iter.h:1119
Forward iterator direction.
Definition: iter.h:29
Item & operator*()
Dereference iterator to get item data reference.
Definition: iter.h:121
IteratorFw(T *obj)
Constructor (used internally).
Definition: iter.h:459
IterType & operator=(const typename IterBaseType::ToggleConst &src)
Assignment operator to copy from source iterator.
Definition: iter.h:986
IteratorBase< T >::Size Size
Size type to use.
Definition: iter.h:914
IteratorFw< T > IterType
Iterator type for parameter passing.
Definition: iter.h:354
IteratorBi< const T > Const
Bidirectional const iterator type.
Definition: iter.h:625
IteratorRa(const IterBaseType &src)
Copy constructor.
Definition: iter.h:967
IteratorBi(T &obj, const Key &key, Item *data)
Constructor.
Definition: iter.h:659
IteratorBase< T >::Item Item
Iterator item type.
Definition: iter.h:623
IteratorBase< T >::Key Key
Iterator key type.
Definition: iter.h:349
IteratorRa(T &obj, const Key &key, Item *data)
Constructor.
Definition: iter.h:957
IterType & operator=(const ToggleConst &src)
Assignment operator to copy from source iterator.
Definition: iter.h:407
This operator++(int)
Post increment operator, moves to next enum value or end.
Definition: iter.h:1323
IteratorFw(T &obj, IteratorPos pos)
Constructor.
Definition: iter.h:373
IterBaseType & operator=(T &obj)
Assignment operator to reset with new object, at end.
Definition: iter.h:104
IteratorBi< typename RemoveConst< T >::Type > Mutable
Bidirectional mutable iterator type.
Definition: iter.h:626
static const IterBaseType & end()
Get iterator at end position.
Definition: iter.h:198
bool end_
Definition: iter.h:1363
IteratorBase< T >::Size Size
Size type to use.
Definition: iter.h:621
IteratorBase< T >::Size Size
Size type to use.
Definition: iter.h:348
IterType & operator=(const IterBaseType &src)
Copy/Assignment operator to copy from source iterator.
Definition: iter.h:677
EnumType value() const
Get current enum value.
Definition: iter.h:1349
#define STATIC_ASSERT(EXP, TOKEN)
Assert compile-time expression is true or trigger compiler error.
Definition: meta.h:54
Key index() const
Get iterator position index.
Definition: iter.h:1156
IteratorFw< const T > Const
Forward const iterator type.
Definition: iter.h:352
IteratorFw(T &obj)
Constructor.
Definition: iter.h:366
#define EVO_PARAM_UNUSED(NAME)
Mark function parameter as unused to suppress "unreferenced parameter" compiler warnings on it...
Definition: sys.h:427
bool operator>=(Key num) const
Greater-than-or-equal operator.
Definition: iter.h:1126
IterType operator-(Size count) const
Subtraction (multi decrement) operator.
Definition: iter.h:1040
IterType & operator=(T &obj)
Assignment operator.
Definition: iter.h:993
IteratorBase(T *obj)
Constructor (used internally).
Definition: iter.h:215
StaticIf< IsConst< T >::value, Mutable, Const >::Type ToggleConst
Used for converting between Const/Mutable iterators.
Definition: iter.h:357
int value_num(int endvalue=0) const
Get current enum number value.
Definition: iter.h:1355
IterType & operator=(T &obj)
Assignment operator.
Definition: iter.h:424
IterType & operator=(IteratorPos pos)
Assignment operator to set position.
Definition: iter.h:702