smrtlink/src/table.cpp

39 lines
757 B
C++
Raw Normal View History

2016-01-16 22:33:04 +00:00
/*
* lookupTable.h
*
* Created on: 11.10.2015
* Author: jdi
*/
#include <string>
#include "table.h"
table::table(std::initializer_list<set> l) {
int i = 0;
this->data.resize(l.size());
for (set s : l) {
this->data[i] = s;
this->left[s.type] = &this->data[i];
this->right[s.name] = &this->data[i];
i++;
}
}
2016-01-17 00:01:49 +00:00
short table::operator[](std::string s){
2016-01-16 22:33:04 +00:00
return this->right[s]->type;
}
2016-01-17 00:01:49 +00:00
std::string table::operator[](short n){
2016-01-16 22:33:04 +00:00
return this->left[n]->name;
}
2016-01-17 00:01:49 +00:00
bool table::exists(std::string s){
2016-01-16 22:33:04 +00:00
return !(right.find(s) == right.end());
}
2016-01-17 00:01:49 +00:00
bool table::exists(short n){
2016-01-16 22:33:04 +00:00
return !(left.find(n) == left.end());
}
2016-01-17 00:01:49 +00:00
const table::set* table::get(std::string s){
2016-01-16 22:33:04 +00:00
return this->right[s];
}
2016-01-17 00:01:49 +00:00
const table::set* table::get(short n){
2016-01-16 22:33:04 +00:00
return this->left[n];
}