3 * \remark This file is part of VITA.
5 * \copyright Copyright (C) 2014-2016 EOS di Manlio Morini.
8 * This Source Code Form is subject to the terms of the Mozilla Public
9 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
10 * You can obtain one at http://mozilla.org/MPL/2.0/
13#if !defined(VITA_GA_I_GA_H)
14# error "Don't include this file directly, include the specific .h instead"
17#if !defined(VITA_INDIVIDUAL_GA_ITERATOR_TCC)
18#define VITA_INDIVIDUAL_GA_ITERATOR_TCC
21/// \brief Iterator to scan the active genes of an individual
23class i_ga::const_iterator
26 using iterator_category = std::forward_iterator_tag;
27 using difference_type = std::ptrdiff_t ;
28 using value_type = locus;
29 using pointer = const value_type *;
30 using reference = const value_type &;
33 /// \brief Builds an empty iterator.
35 /// Empty iterator is used as sentry (it is the value returned by
38 const_iterator() : sup_(0), i_(std::numeric_limits<decltype(i_)>::max()) {}
41 /// \param[in] id an individual.
43 explicit const_iterator(const i_ga &id) : sup_(id.parameters()), i_(0)
48 /// \return locus of the next active symbol.
50 const_iterator &operator++()
55 i_ = std::numeric_limits<decltype(i_)>::max();
61 /// \param[in] rhs second term of comparison.
63 /// Returns `true` if iterators point to the same locus.
65 bool operator==(const const_iterator &rhs) const
70 bool operator!=(const const_iterator &rhs) const
72 return !(*this == rhs);
76 /// \return the current locus of the individual.
78 value_type operator*() const
84 const category_t sup_;
86}; // class i_ga::const_iterator
88#endif // Include guard