OpenFPM  5.2.0
Project that contain the implementation of distributed structures
vector_dist_iterator.hpp
1 /*
2  * vector_dist_iterator.hpp
3  *
4  * Created on: Mar 10, 2015
5  * Author: Pietro Incardona
6  */
7 
8 #ifndef VECTOR_DIST_ITERATOR_HPP_
9 #define VECTOR_DIST_ITERATOR_HPP_
10 
11 #include "Vector/vector_dist_key.hpp"
12 #include "VCluster/VCluster.hpp"
13 
16 {
18  size_t v_it;
19 
21  size_t stop;
22 
23  public:
24 
31  vector_dist_iterator(size_t start, size_t stop)
32  :v_it(start),stop(stop)
33  {
34  }
35 
36  // Destructor
38  {
39  }
40 
48  {
49  ++v_it;
50 
51  return *this;
52  }
53 
60  bool isNext()
61  {
62  // If there are no other grid stop
63 
64  if (v_it >= stop)
65  return false;
66 
67  return true;
68  }
69 
76  {
78  v.setKey(v_it);
79  return v;
80  }
81 
86  void reset()
87  {
88  v_it = 0;
89  }
90 };
91 
92 
95 {
97  size_t v_it;
98 
100  size_t stop;
101 
102  const openfpm::vector<aggregate<int>> & pid;
103 
104  public:
105 
113  :v_it(start),stop(stop),pid(pid)
114  {
115  }
116 
117  // Destructor
119  {
120  }
121 
129  {
130  ++v_it;
131 
132  return *this;
133  }
134 
141  bool isNext()
142  {
143  // If there are no other grid stop
144 
145  if (v_it >= stop)
146  return false;
147 
148  return true;
149  }
150 
157  {
159  v.setKey(pid.template get<0>(v_it));
160  return v;
161  }
162 
169  {
171  v.setKey(v_it);
172  return v;
173  }
174 
179  void reset()
180  {
181  v_it = 0;
182  }
183 };
184 
185 #endif /* VECTOR_DIST_ITERATOR_HPP_ */
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:204
Grid key for a distributed grid.
Iterator that Iterate across particle indexes.
vect_dist_key_dx getSubset()
Get the subset key.
vect_dist_key_dx get()
Get the actual key.
bool isNext()
Check if there is the next element.
void reset()
Reset the iterator.
vector_dist_iterator_subset & operator++()
Get the next element.
vector_dist_iterator_subset(size_t start, size_t stop, const openfpm::vector< aggregate< int >> &pid)
Constructor of the distributed grid.
Iterator that Iterate across particle indexes.
bool isNext()
Check if there is the next element.
void reset()
Reset the iterator.
vect_dist_key_dx get()
Get the actual key.
vector_dist_iterator(size_t start, size_t stop)
Constructor of the distributed grid.
vector_dist_iterator & operator++()
Get the next element.
size_t v_it
Actual iterator.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
Definition: aggregate.hpp:221