root/ggpa/VariableAssignmentIterator.h

Revision 1, 1.6 kB (checked in by pantley2, 4 years ago)

GGPA code from the good old days of SIGART

Line 
1 /*
2  * VariableAssignmentIterator
3  * Helper class to iterate through the different assignments of variables
4  */
5
6 #ifndef VARIABLEASSIGNMENTITERATOR_H
7 #define VARIABLEASSIGNMENTITERATOR_H
8
9 #include <map>
10 #include <vector>
11 #include <iostream>
12
13 using namespace std;
14
15 class VariableAssignmentIterator {
16
17  private:
18     //vector storing the possible values for each variable
19     //vector<vector<string> > possibleValues;
20
21     //map storing the current indices representing the values for each variable
22     map<string, unsigned int> indexValues;
23
24     // mapping from variable names to their possible values
25     map<string, vector<string> > possibleValues;
26
27     // a list of the variable names
28     vector<string> variables;
29
30     // a boolean indicating that the iterator has traversed all possiblities.
31     bool done;
32
33  public:
34    
35     /**
36      * Constructor
37      * Parameters:  variableMap - a map from variable names to their set
38      *                            of possible values
39      * Initializes the VariableAssignmentIterator
40      */
41     VariableAssignmentIterator(const map<string, vector<string> >& variableMap);
42    
43     /**
44      * next
45      * No parameters or return type.
46      * Move to the next value mapping
47      */
48     void next();
49
50     /**
51      * getCurrent
52      * No parameters.
53      * Return type: map from strings to strings
54      * Returns the current mapping from variable name to variable value
55      */
56     map<string, string> getCurrent();
57
58     /**
59      * atEnd
60      * Parameters: none
61      * Return type: bool
62      * Returns true if there are no more mappings of variables, and false
63      * otherwise.
64      */
65     bool atEnd() const;
66
67 };
68
69 #endif
70
Note: See TracBrowser for help on using the browser.