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  return linearIndex_ != other.linearIndex_;
35 }
36 
38 {
40 }
41 
42 const size_t& GridMapIterator::getLinearIndex() const
43 {
44  return linearIndex_;
45 }
46 
48 {
49  return getIndexFromBufferIndex(*(*this), size_, startIndex_);
50 }
51 
53 {
54  size_t newIndex = linearIndex_ + 1;
55  if (newIndex < linearSize_) {
56  linearIndex_ = newIndex;
57  } else {
58  isPastEnd_ = true;
59  }
60  return *this;
61 }
62 
64 {
65  GridMapIterator res(this);
66  res.linearIndex_ = linearSize_ - 1;
67  return res;
68 }
69 
71 {
72  return isPastEnd_;
73 }
74 
75 } /* namespace grid_map */
bool operator!=(const GridMapIterator &other) const
const Index & getStartIndex() const
Definition: GridMap.cpp:669
Index getIndexFromBufferIndex(const Index &bufferIndex, const Size &bufferSize, const Index &bufferStartIndex)
const Size & getSize() const
Definition: GridMap.cpp:661
size_t linearIndex_
Linear index.
GridMapIterator end() const
bool isPastEnd_
Is iterator out of scope.
Size size_
Size of the buffer.
Eigen::Array2i Index
Definition: TypeDefs.hpp:22
const size_t & getLinearIndex() const
size_t linearSize_
Linear size of the data.
GridMapIterator(const grid_map::GridMap &gridMap)
virtual GridMapIterator & operator++()
Index startIndex_
Start index of the circular buffer.
Index getIndexFromLinearIndex(size_t linearIndex, const Size &bufferSize, bool rowMajor=false)


grid_map_core
Author(s): Péter Fankhauser
autogenerated on Wed Jul 5 2023 02:23:35