-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack with linked list
More file actions
52 lines (45 loc) · 1.04 KB
/
Stack with linked list
File metadata and controls
52 lines (45 loc) · 1.04 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
#include <iostream>
#include <vector>
using namespace std;
template <typename type_key,typename type_body>
struct Row{
type_key key;
type_body body;
Row(type_key key, type_body body) : key(key), body(body) {}
};
template <typename type_key,typename type_body>
class Table{
private:
vector<Row<type_key,type_body>> table;
public:
void add(type_key key,type_body body){
table.push_back(Row(key,body));
}
bool find(type_key key){
bool find=false;
for(int i=0;i<table.size();i++){
if(table.at(i).key==key){
return true;
}
}
}
int find_return_num(type_key key){
for(int i=0;i<table.size();i++){
if(table.at(i).key==key){
return i;
}
}
}
void delete_element(type_key key){
table.erase(find_return_num(key));
int k;
}
};
int main(){
Table<int,int> table;
table.add(4,7);
table.add(11,8);
table.delete_element(11);
cout<<table.find(4);
return 0 ;
};