GridMapIterator.cpp
Go to the documentation of this file.
1 /*
2  * GridMapIterator.cpp
3  *
4  * Created on: Sep 22, 2014
5  * Author: Péter Fankhauser
6  * Institute: ETH Zurich, ANYbotics
7  */
8 
11 
12 namespace grid_map {
13 
15 {
16  size_ = gridMap.getSize();
17  startIndex_ = gridMap.getStartIndex();
18  linearSize_ = size_.prod();
19  linearIndex_ = 0;
20  isPastEnd_ = false;
21 }
22 
24 {
25  size_ = other->size_;
26  startIndex_ = other->startIndex_;
27  linearSize_ = other->linearSize_;
28  linearIndex_ = other->linearIndex_;
29  isPastEnd_ = other->isPastEnd_;
30 }
31 
33 {
34  size_ = other.size_;
35  startIndex_ = other.startIndex_;
36  linearSize_ = other.linearSize_;
37  linearIndex_ = other.linearIndex_;
38  isPastEnd_ = other.isPastEnd_;
39  return *this;
40 }
41 
43 {
44  return linearIndex_ != other.linearIndex_;
45 }
46 
48 {
50 }
51 
52 const size_t& GridMapIterator::getLinearIndex() const
53 {
54  return linearIndex_;
55 }
56 
58 {
59  return getIndexFromBufferIndex(*(*this), size_, startIndex_);
60 }
61 
63 {
64  size_t newIndex = linearIndex_ + 1;
65  if (newIndex < linearSize_) {
66  linearIndex_ = newIndex;
67  } else {
68  isPastEnd_ = true;
69  }
70  return *this;
71 }
72 
74 {
75  GridMapIterator res(this);
76  res.linearIndex_ = linearSize_ - 1;
77  return res;
78 }
79 
81 {
82  return isPastEnd_;
83 }
84 
85 } /* namespace grid_map */
Eigen::Array2i Index
Definition: TypeDefs.hpp:22
const Index & getStartIndex() const
Definition: GridMap.cpp:679
GridMapIterator & operator=(const GridMapIterator &other)
Index getIndexFromBufferIndex(const Index &bufferIndex, const Size &bufferSize, const Index &bufferStartIndex)
const Index operator*() const
size_t linearIndex_
Linear index.
bool isPastEnd_
Is iterator out of scope.
Size size_
Size of the buffer.
size_t linearSize_
Linear size of the data.
Index getIndexFromLinearIndex(const size_t linearIndex, const Size &bufferSize, const bool rowMajor=false)
const Index getUnwrappedIndex() const
GridMapIterator(const grid_map::GridMap &gridMap)
GridMapIterator end() const
virtual GridMapIterator & operator++()
Index startIndex_
Start index of the circular buffer.
bool operator!=(const GridMapIterator &other) const
const size_t & getLinearIndex() const
const Size & getSize() const
Definition: GridMap.cpp:670


grid_map_core
Author(s): Péter Fankhauser
autogenerated on Tue Jun 25 2019 20:02:08