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;
19  IndexIterator(size_t index) : m_index(index) {}
20  const size_t operator*() const
21  {
22  return m_index;
23  }
24  const size_t* operator->() const
25  {
26  return &m_index;
27  }
29  {
30  ++m_index;
31  return *this;
32  }
34  {
35  size_t save = m_index;
36  ++m_index;
37  return IndexIterator(save);
38  }
40  {
41  return m_index == a.m_index;
42  }
44  {
45  return m_index != a.m_index;
46  }
47  IndexIterator& operator+=(size_t offset)
48  {
49  m_index += offset;
50  return *this;
51  }
52  IndexIterator& operator-=(size_t offset)
53  {
54  m_index -= offset;
55  return *this;
56  }
57  IndexIterator operator+(size_t offset) const
58  {
59  return IndexIterator(m_index + offset);
60  }
61  IndexIterator operator-(size_t offset) const
62  {
63  return IndexIterator(m_index - offset);
64  }
65  size_t operator-(IndexIterator i) const
66  {
67  return m_index - i.m_index;
68  }
69 
70  size_t operator[](size_t i) const
71  {
72  return m_index + i;
73  }
74 
75 private:
76  size_t m_index;
77 };
78 
79 #endif
IndexIterator::operator-
IndexIterator operator-(size_t offset) const
Definition: IndexIterator.h:61
DLL_LINKAGE
#define DLL_LINKAGE
Definition: IndexIterator.h:6
index
uint8_t index
Definition: EtherCATFrame.h:59
IndexIterator::IndexIterator
IndexIterator()
Definition: IndexIterator.h:18
IndexIterator::IndexIterator
IndexIterator(size_t index)
Definition: IndexIterator.h:19
IndexIterator::operator!=
bool operator!=(IndexIterator a) const
Definition: IndexIterator.h:43
IndexIterator::operator++
IndexIterator operator++(int)
Definition: IndexIterator.h:33
IndexIterator::difference_type
size_t difference_type
Definition: IndexIterator.h:17
IndexIterator::operator+
IndexIterator operator+(size_t offset) const
Definition: IndexIterator.h:57
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:28
armarx::navigation::algorithms::save
bool save(const Costmap &costmap, const std::filesystem::path &directory)
Definition: persistence.cpp:101
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:20
IndexIterator::operator==
bool operator==(IndexIterator a) const
Definition: IndexIterator.h:39
IndexIterator::operator+=
IndexIterator & operator+=(size_t offset)
Definition: IndexIterator.h:47
IndexIterator::operator-
size_t operator-(IndexIterator i) const
Definition: IndexIterator.h:65
IndexIterator::operator[]
size_t operator[](size_t i) const
Definition: IndexIterator.h:70
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:24
IndexIterator
Definition: IndexIterator.h:9
IndexIterator::operator-=
IndexIterator & operator-=(size_t offset)
Definition: IndexIterator.h:52