-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtile_view_iterator.hpp
59 lines (43 loc) · 1.33 KB
/
tile_view_iterator.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* tile_view_iterator.hpp
*
* Created on: Nov 5, 2016
* Author: pfandedd
*/
#pragma once
#include "hpx/util/iterator_facade.hpp"
#include "tile_view.hpp"
namespace memory_layout {
template<size_t dim, typename T>
class tile_view_iterator: public hpx::util::iterator_facade<tile_view_iterator<dim, T>, T, std::forward_iterator_tag, const T&> {
private:
// typedef hpx::util::iterator_facade<tile_view_iterator<T>, T, std::forward_iterator_tag, T&> base_type;
friend class hpx::util::iterator_core_access;
size_t inner_flat_index;
std::reference_wrapper<tile_view<dim, T>> v;
void increment() {
inner_flat_index += 1;
}
bool equal(tile_view_iterator const& other) const {
return inner_flat_index == other.inner_flat_index;
}
const T &dereference() const {
return v.get()[inner_flat_index];
}
public:
tile_view_iterator(tile_view<dim, T> &v) :
inner_flat_index(0), v(v) {
}
tile_view_iterator(tile_view<dim, T> &v, const size_t (&start_coord)[dim]) :
v(v) {
inner_flat_index = v.flat_index(start_coord);
}
tile_view_iterator &operator=(tile_view_iterator const &other) {
if (this != &other) {
inner_flat_index = other.inner_flat_index;
v = other.v;
}
return *this;
}
};
}