-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTuple.h
More file actions
61 lines (47 loc) · 1.18 KB
/
Tuple.h
File metadata and controls
61 lines (47 loc) · 1.18 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
53
54
55
56
57
58
59
60
61
//
// Created by deck on 7/21/24.
//
#ifndef TUPLE_H
#define TUPLE_H
#pragma once
#include <iostream>
#include <vector>
#include "Scheme.h"
#include <sstream>
using namespace std;
class Tuple {
private:
vector<string> values;
public:
Tuple(vector<string> values) : values(values) { }
unsigned size() const {
return values.size();
}
const string& at(int index) const {
return values.at(index);
}
const vector<string> &getValues() const {
return values;
}
bool operator<(const Tuple t) const {
return values < t.values;
}
string toString(const Scheme& scheme) const {
const Tuple& tuple = *this;
stringstream out;
for (size_t i = 0; i < scheme.size(); ++i) {
out << scheme.at(i) << "=" << tuple.at(i)<< "";
if (i < scheme.size() - 1) {
out << ", ";
}
}
// fix the code to print "name=value" pairs
// out << scheme.size();
// out << scheme.at(0);
// out << tuple.size();
// out << tuple.at(0);
return out.str();
}
// TODO: add more delegation functions as needed
};
#endif //TUPLE_H