OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
vector_map_iterator.hpp
1/*
2 * vector_map_iterator.hpp
3 *
4 * Created on: Apr 1, 2017
5 * Author: i-bird
6 */
7
8#ifndef OPENFPM_DATA_SRC_VECTOR_VECTOR_MAP_ITERATOR_HPP_
9#define OPENFPM_DATA_SRC_VECTOR_VECTOR_MAP_ITERATOR_HPP_
10
11namespace openfpm
12{
16 template<unsigned int p, typename vector_type>
18 {
21
22 size_t end;
23
24 protected:
25
27 size_t gk;
28
29 public:
30
37 vector_key_iterator_ele(const vector_type & vect, size_t end, size_t start = 0)
38 : vect(vect),end(end),gk(start)
39 {}
40
41
50 {
52
53 gk++;
54
55 return *this;
56 }
57
64 void set(int d, size_t sz)
65 {
66 // set the counter dim to sz
67
68 gk = sz;
69 }
70
78 bool isNext() const
79 {
80 if (gk < end)
81 {
83
84 return true;
85 }
86
88 return false;
89 }
90
98 auto get() const -> decltype(vect.template get<p>(gk))
99 {
100 return vect.template get<p>(gk);
101 }
102 };
103
109 {
111 size_t end;
112
113 protected:
114
116 size_t gk;
117
118 public:
119
126 vector_key_iterator(size_t end, size_t start = 0)
127 : end(end),gk(start)
128 {}
129
130
139 {
141
142 gk++;
143
144 return *this;
145 }
146
153 void set(int d, size_t sz)
154 {
155 // set the counter dim to sz
156
157 gk = sz;
158 }
159
167 bool isNext() const
168 {
169 if (gk < end)
170 {
172
173 return true;
174 }
175
177 return false;
178 }
179
187 size_t get() const
188 {
189 return gk;
190 }
191 };
192
199 template<typename lid>
201 {
203
204 protected:
205
207 size_t gk;
208
209 public:
210
217 :dp(dp),gk(0)
218 {}
219
220
229 {
231
232 gk++;
233
234 return *this;
235 }
236
243 void set(int d, size_t sz)
244 {
245 // set the counter dim to sz
246
247 gk = sz;
248 }
249
257 bool isNext() const
258 {
259 if (gk < dp.size())
260 {
262
263 return true;
264 }
265
267 return false;
268 }
269
277 size_t get() const
278 {
279 return dp.get(gk);
280 }
281 };
282}
283
284
285#endif /* OPENFPM_DATA_SRC_VECTOR_VECTOR_MAP_ITERATOR_HPP_ */
vector_key_iterator_ele & operator++()
Get the next element.
auto get() const -> decltype(vect.template get< p >(gk))
Get the actual key.
const vector_type & vect
Linearized end element.
void set(int d, size_t sz)
Set the dimension.
bool isNext() const
Check if there is the next element.
vector_key_iterator_ele(const vector_type &vect, size_t end, size_t start=0)
Constructor require the size of the vector.
vector_key_iterator_seq(openfpm::vector< lid > &dp)
Constructor require the sequence.
void set(int d, size_t sz)
Set the dimension.
size_t get() const
Get the actual key.
bool isNext() const
Check if there is the next element.
vector_key_iterator_seq< lid > & operator++()
Get the next element.
size_t end
Linearized end element.
void set(int d, size_t sz)
Set the dimension.
size_t get() const
Get the actual key.
vector_key_iterator(size_t end, size_t start=0)
Constructor require the size of the vector.
vector_key_iterator & operator++()
Get the next element.
bool isNext() const
Check if there is the next element.
Implementation of 1-D std::vector like structure.
Distributed vector.
convert a type into constant type