IndexIterator.h
Go to the documentation of this file.
1 #ifndef INDEXITERATOR_HEADER
2 #define INDEXITERATOR_HEADER
3 #include <iterator>
4 
5 #ifndef DLL_LINKAGE
6 #define DLL_LINKAGE
7 #endif
8 
10 {
11 public:
12  typedef const size_t value_type;
13  typedef value_type* pointer;
14  typedef value_type& reference;
15  typedef std::forward_iterator_tag iterator_category;
16  typedef size_t size_type;
17  typedef size_t difference_type;
18 
20  {
21  }
22 
23  IndexIterator(size_t index) : m_index(index)
24  {
25  }
26 
27  const size_t
28  operator*() const
29  {
30  return m_index;
31  }
32 
33  const size_t*
34  operator->() const
35  {
36  return &m_index;
37  }
38 
41  {
42  ++m_index;
43  return *this;
44  }
45 
48  {
49  size_t save = m_index;
50  ++m_index;
51  return IndexIterator(save);
52  }
53 
54  bool
56  {
57  return m_index == a.m_index;
58  }
59 
60  bool
62  {
63  return m_index != a.m_index;
64  }
65 
67  operator+=(size_t offset)
68  {
69  m_index += offset;
70  return *this;
71  }
72 
74  operator-=(size_t offset)
75  {
76  m_index -= offset;
77  return *this;
78  }
79 
81  operator+(size_t offset) const
82  {
83  return IndexIterator(m_index + offset);
84  }
85 
87  operator-(size_t offset) const
88  {
89  return IndexIterator(m_index - offset);
90  }
91 
92  size_t
94  {
95  return m_index - i.m_index;
96  }
97 
98  size_t
99  operator[](size_t i) const
100  {
101  return m_index + i;
102  }
103 
104 private:
105  size_t m_index;
106 };
107 
108 #endif
IndexIterator::operator-
IndexIterator operator-(size_t offset) const
Definition: IndexIterator.h:87
DLL_LINKAGE
#define DLL_LINKAGE
Definition: IndexIterator.h:6
index
uint8_t index
Definition: EtherCATFrame.h:59
IndexIterator::IndexIterator
IndexIterator()
Definition: IndexIterator.h:19
IndexIterator::IndexIterator
IndexIterator(size_t index)
Definition: IndexIterator.h:23
IndexIterator::operator!=
bool operator!=(IndexIterator a) const
Definition: IndexIterator.h:61
IndexIterator::operator++
IndexIterator operator++(int)
Definition: IndexIterator.h:47
IndexIterator::difference_type
size_t difference_type
Definition: IndexIterator.h:17
IndexIterator::operator+
IndexIterator operator+(size_t offset) const
Definition: IndexIterator.h:81
IndexIterator::reference
value_type & reference
Definition: IndexIterator.h:14
IndexIterator::value_type
const typedef size_t value_type
Definition: IndexIterator.h:12
IndexIterator::iterator_category
std::forward_iterator_tag iterator_category
Definition: IndexIterator.h:15
IndexIterator::operator++
IndexIterator & operator++()
Definition: IndexIterator.h:40
armarx::navigation::algorithms::save
bool save(const Costmap &costmap, const std::filesystem::path &directory)
Definition: persistence.cpp:114
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
IndexIterator::operator*
const size_t operator*() const
Definition: IndexIterator.h:28
IndexIterator::operator==
bool operator==(IndexIterator a) const
Definition: IndexIterator.h:55
IndexIterator::operator+=
IndexIterator & operator+=(size_t offset)
Definition: IndexIterator.h:67
IndexIterator::operator-
size_t operator-(IndexIterator i) const
Definition: IndexIterator.h:93
IndexIterator::operator[]
size_t operator[](size_t i) const
Definition: IndexIterator.h:99
IndexIterator::pointer
value_type * pointer
Definition: IndexIterator.h:13
IndexIterator::size_type
size_t size_type
Definition: IndexIterator.h:16
IndexIterator::operator->
const size_t * operator->() const
Definition: IndexIterator.h:34
IndexIterator
Definition: IndexIterator.h:9
IndexIterator::operator-=
IndexIterator & operator-=(size_t offset)
Definition: IndexIterator.h:74