Exemplo n.º 1
0
Scheme Relation::join_scheme(Relation r2) {
	Scheme s = Scheme();

	// Put in the whole first scheme
	for (auto var : this->scheme)
		s.push_back(var);

	// Put in any additional vars from the second scheme
	for (auto var1 : this->scheme) {
		for (auto var2 : r2.scheme) {
			if (std::find(s.begin(), s.end(), var2) == s.end()) {
				s.push_back(var2);
			}
		}
	}

	return s;
}
Exemplo n.º 2
0
void Interpretter::evalSchemes(vector <Predicate>& schemeList) {
    output += "Scheme Evaluation\n\n";
    for (Predicate scheme : schemeList) {      //a list of predicates
        set <Tuple> tuples;
        Scheme s;
        for (auto param : scheme.getParams()) {
            s.push_back(param.toString());      //for whatever reason, we can't have objects used from previous labs, so dump to string here
        }
        Relation r(scheme.getID(), s, tuples); //scheme.getParams() needs to be a set
        db[r.getName()] = r;
        //add relation to database
    }
}