vector_dist_iterator.hpp 1.27 KB
Newer Older
incardon's avatar
incardon committed
1 2 3 4 5 6 7 8 9 10
/*
 * vector_dist_iterator.hpp
 *
 *  Created on: Mar 10, 2015
 *      Author: Pietro Incardona
 */

#ifndef VECTOR_DIST_ITERATOR_HPP_
#define VECTOR_DIST_ITERATOR_HPP_

incardon's avatar
incardon committed
11
#include "Vector/vector_dist_key.hpp"
incardon's avatar
incardon committed
12
#include "VCluster/VCluster.hpp"
incardon's avatar
incardon committed
13

incardon's avatar
incardon committed
14
//! Iterator that Iterate across particle indexes
incardon's avatar
incardon committed
15 16 17 18 19
class vector_dist_iterator
{
	//! Actual iterator
	size_t v_it;

incardon's avatar
incardon committed
20
	//! end point
21 22
	size_t stop;

incardon's avatar
incardon committed
23 24 25 26
	public:

	/*! \brief Constructor of the distributed grid
	 *
incardon's avatar
incardon committed
27 28
	 * \param start start point
	 * \param stop end point
incardon's avatar
incardon committed
29 30
	 *
	 */
31 32
	vector_dist_iterator(size_t start, size_t stop)
	:v_it(start),stop(stop)
incardon's avatar
incardon committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46
	{
	}

	// Destructor
	~vector_dist_iterator()
	{
	}

	/*! \brief Get the next element
	 *
	 * \return the next grid_key
	 *
	 */

47
	vector_dist_iterator & operator++()
incardon's avatar
incardon committed
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
	{
		++v_it;

		return *this;
	}

	/*! \brief Check if there is the next element
	 *
	 * \return true if there is the next, false otherwise
	 *
	 */

	bool isNext()
	{
		// If there are no other grid stop

64
		if (v_it >= stop)
incardon's avatar
incardon committed
65 66 67 68 69 70 71 72 73 74
			return false;

		return true;
	}

	/*! \brief Get the actual key
	 *
	 * \return the actual key
	 *
	 */
75
	inline vect_dist_key_dx get()
incardon's avatar
incardon committed
76
	{
77 78 79
		vect_dist_key_dx v;
		v.setKey(v_it);
		return v;
incardon's avatar
incardon committed
80
	}
81 82 83 84 85 86 87 88 89

	/*! \brief Reset the iterator
	 *
	 *
	 */
	void reset()
	{
		v_it = 0;
	}
incardon's avatar
incardon committed
90 91 92 93
};


#endif /* VECTOR_DIST_ITERATOR_HPP_ */