-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTuple.h
53 lines (38 loc) · 955 Bytes
/
Tuple.h
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
53
#include <vector>
#include <string>
#include "Scheme.h"
#pragma once
using namespace std;
class Tuple {
private:
vector<string> values;
public:
Tuple () {}
Tuple(vector<string> values) : values(values) { }
unsigned size() const {
return values.size();
}
const string& at(int index) const {
return values.at(index);
}
void push_back(const string& value) {
values.push_back(value);
}
bool operator<(const Tuple t) const {
return values < t.values;
}
string toString(const Scheme& scheme) const {
const Tuple& tuple = *this;
stringstream out;
// fix the code to print "name=value" pairs
for (unsigned i=0; i < scheme.size(); i++) {
out << scheme.at(i);
out << "=";
out << tuple.at(i);
if (i != scheme.size() - 1) // Check if it's not the last iteration
out << ", ";
}
return out.str();
}
// TODO: add more delegation functions as needed
};