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
14//! Iterator that Iterate across particle indexes
15class vector_dist_iterator
16{
17 //! Actual iterator
18 size_t v_it;
19
20 //! end point
21 size_t stop;
22
23 public:
24
25 /*! \brief Constructor of the distributed grid
26 *
27 * \param start start point
28 * \param stop end point
29 *
30 */
31 vector_dist_iterator(size_t start, size_t stop)
32 :v_it(start),stop(stop)
33 {
34 }
35
36 // Destructor
37 ~vector_dist_iterator()
38 {
39 }
40
41 /*! \brief Get the next element
42 *
43 * \return the next grid_key
44 *
45 */
46
47 vector_dist_iterator & operator++()
48 {
49 ++v_it;
50
51 return *this;
52 }
53
54 /*! \brief Check if there is the next element
55 *
56 * \return true if there is the next, false otherwise
57 *
58 */
59
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
70 /*! \brief Get the actual key
71 *
72 * \return the actual key
73 *
74 */
75 inline vect_dist_key_dx get()
76 {
77 vect_dist_key_dx v;
78 v.setKey(v_it);
79 return v;
80 }
81
82 /*! \brief Reset the iterator
83 *
84 *
85 */
86 void reset()
87 {
88 v_it = 0;
89 }
90};
91
92
93#endif /* VECTOR_DIST_ITERATOR_HPP_ */
94