Percy++
A C++ implementation of Private Information Retrieval (PIR) protocols
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
subset_iter.h
1 // Percy++ Copyright 2007,2012,2013,2014
2 // Ian Goldberg <iang@cs.uwaterloo.ca>,
3 // Casey Devet <cjdevet@uwaterloo.ca>,
4 // Ryan Henry <rhenry@cs.uwaterloo.ca>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of version 2 of the GNU General Public License as
8 // published by the Free Software Foundation.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // There is a copy of the GNU General Public License in the COPYING file
16 // packaged with this plugin; if you cannot find it, write to the Free
17 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 
20 #ifndef __SUBSET_ITER_H__
21 #define __SUBSET_ITER_H__
22 
23 #include <vector>
24 #include "percytypes.h"
25 
26 // Produce all subsets of a given vector<nservers_t> of a given size
27 //
28 // Usage:
29 // vector<nservers_t> G;
30 // ...
31 // subset_iterator iter(G, k);
32 // while(!iter.atend()) {
33 // do_something_with(*iter);
34 // ++iter;
35 // }
36 
38 private:
39  std::vector<nservers_t> source;
40  std::vector<nservers_t> indices;
41  std::vector<nservers_t> output;
42  nservers_t subset_size;
43  bool finished;
44 public:
45  subset_iterator(const std::vector<nservers_t>& source,
46  nservers_t subset_size);
47  subset_iterator& operator++();
48  const std::vector<nservers_t>& operator*() const;
49  bool atend() const;
50 };
51 
52 #endif
Definition: subset_iter.h:37
This header contains typedefs for seamless switching between 32- and 64-bit builds of Percy++...