27class Combination_iterator
28 :
public boost::iterator_facade<Combination_iterator, std::vector<uint> const, boost::forward_traversal_tag> {
29 typedef std::vector<uint> value_t;
32 friend class boost::iterator_core_access;
34 bool equal(Combination_iterator
const& other)
const {
return (is_end_ && other.is_end_); }
36 value_t
const& dereference()
const {
return value_; }
39 if (value_[0] == n_ - k_) {
44 if (value_[j] < n_ - 1) {
49 if (value_[j - 1] < n_ - k_ + j - 1) {
51 for (uint s = j; s < k_; s++) value_[s] = value_[j - 1] + s - (j - 1);
57 Combination_iterator(
const uint& n,
const uint& k) : value_(k), is_end_(n == 0), n_(n), k_(k) {
58 for (uint i = 0; i < k; ++i) value_[i] = i;
62 Combination_iterator() : is_end_(
true), n_(0), k_(0) {}
67 for (uint i = 0; i < n_; ++i) value_[i] = i;