Repository navigation
Expand file tree
/
Copy pathsubset_iter.h
More file actions
52 lines (47 loc) · 1.59 KB
/
Copy pathsubset_iter.h
File metadata and controls
52 lines (47 loc) · 1.59 KB
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
// Percy++ Copyright 2007,2012 Ian Goldberg <iang@cs.uwaterloo.ca>,
// Casey Devet <cjdevet@cs.uwaterloo.ca>,
// Paul Hendry <pshdenry@uwaterloo.ca>,
// Ryan Henry <rhenry@cs.uwaterloo.ca>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of version 2 of the GNU General Public License as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// There is a copy of the GNU General Public License in the COPYING file
// packaged with this plugin; if you cannot find it, write to the Free
// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301 USA
#ifndef __SUBSET_ITER_H__
#define __SUBSET_ITER_H__
#include <vector>
#include "percytypes.h"
// Produce all subsets of a given vector<nservers_t> of a given size
//
// Usage:
// vector<nservers_t> G;
// ...
// subset_iterator iter(G, k);
// while(!iter.atend()) {
// do_something_with(*iter);
// ++iter;
// }
class subset_iterator {
private:
std::vector<nservers_t> source;
std::vector<nservers_t> indices;
std::vector<nservers_t> output;
nservers_t subset_size;
bool finished;
public:
subset_iterator(const std::vector<nservers_t>& source,
nservers_t subset_size);
subset_iterator& operator++();
const std::vector<nservers_t>& operator*() const;
bool atend() const;
};
#endif