-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtds.cpp
56 lines (44 loc) · 937 Bytes
/
tds.cpp
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
#include<map>
#include<iostream>
#include"tds.h"
using namespace std;
/*enum IDType {FUNC,VAR};
struct symrec {
IDType idtype;
string source;
};*/
map<string,symrec> tds;
bool TDSget(string symbol, symrec * out){
map<string,symrec>::iterator it;
it = tds.find(symbol);
bool res = it != tds.end();
if(res)
*out = it->second;
return res;
}
bool TDSinsert(string symbol, symrec sr){
pair<map<string,symrec>::iterator,bool> ret;
ret = tds.insert(pair<string,symrec>(symbol,sr));
return ret.second;
}
int TDSremove(string symbol){
int ret;
ret = tds.erase(symbol);
return ret;
}
/*int main(){
symrec sr,sr1;
bool sm = TDSget("toto",&sr);
if(!sm){
cout << "toto not found endl" << endl;
}
sr.source = "vasyfranky";
TDSinsert("toto",sr);
sm = TDSget("toto",&sr1);
if(!sm){
cout << "toto not found endl" << endl;
}else {
cout << "toto contains :" + sr1.source << endl;
}
TDSinsert("toto",sr);
}*/