#include<bits/stdc++.h>
using namespace std;


struct symbolInfo{
     string name;
     string type;
};

class symbolTable{
     vector<symbolInfo> vec[10];
 public:
    int hashfunction(string name)
    {
        int sum=0;
        int len= name.length();
        for(int i=0; i<len; i++)
        {
            sum+=name[i];
        }
        return sum%10;
    }

    void insertt(string name, string type)
    {
        symbolInfo *ob= new symbolInfo(); ///not mandatory
        ob->name=name;  ///not mandatory
        ob->type=type;   ///not mandatory
        int hashval=hashfunction(name);
        vector<symbolInfo>v= vec[hashval];
        int flag=0;

        for(auto findd=v.begin(); findd!=v.end(); findd++)
        {
            if(findd->name==name && findd->type==type)
            {
                flag=1;
                break;
            }
        }
        if(flag==0)
        {
            vec[hashval].push_back(*ob);
            cout << "Symbol inserted successfully" << endl;
        }
        else{
            cout << "Symbol already inserted" << endl;
        }
    }

    void lookup(string name, string type)
    {
        symbolInfo *ob= new symbolInfo(); ///not mandatory
        ob->name=name;  ///not mandatory
        ob->type=type;   ///not mandatory
        int hashval=hashfunction(name);
        vector<symbolInfo>v= vec[hashval];
        int flag=0;

        for(auto findd=v.begin(); findd!=v.end(); findd++)
        {
            if(findd->name==name && findd->type==type)
            {
                flag=1;
                break;
            }
        }
        if(flag==0)
        {
            cout << " Not Found" << endl;
        }
        else{
            cout << "Found" << endl;
        }
    }


    void deletee(string name,string type)
    {
        symbolInfo *ob= new symbolInfo(); ///not mandatory
        ob->name=name;  ///not mandatory
        ob->type=type;   ///not mandatory
        int hashval=hashfunction(name);
        vector<symbolInfo>v= vec[hashval];
        int flag=0;
        int cnt=0;
        for(auto findd=v.begin(); findd!=v.end(); findd++)
        {    cnt++;
            if(findd->name==name && findd->type==type)
            {
                flag=1;
                break;
            }
        }
        if(flag==0)
        {
            cout << "symbol doesn't exist" << endl;
        }
        else{
             vec[hashval].erase(v.begin()+ cnt);
            cout << "Deleted" << endl;
        }
    }

    void print()
    {
        vector<symbolInfo>::iterator it;
        for(int i=0; i<10; i++)
        {
            cout << i << "--->";
            for(auto it:vec[i])
            {
                cout <<"<" << it.name << "," << it.type << ">" ;
            }
            cout << endl;
        }
    }
};
int main()
{
   symbolTable s;
   s.insertt("int","id");
   s.lookup("int","id");
   s.deletee("int","id");
   s.lookup("int","id");
   }


/*
0->
1->int->main->=
2->4->*->/
3->div
4->mul->float
5->
6->
7->a->9
8->b
9->c->1
*/
