1

このような挿入機能を使用して、ハッシュ テーブルからエントリを削除するにはどうすればよいのでしょうか。

class HashTable{
    public int hash(int id){ return id%10;}

    private HNode[] head=new HNode[10];
    
    public  HashTable(){for(int i=0;i<10;i++)head[i]=null;}

    public  void insert(int k, String nm, int a, String g, String mOB, int c, String add, int pn)
        {      HNode temp =new HNode(k,nm,a,g,mOB,c,add,pn);
               int index=hash(k);
               temp.next=head[index];
               head[index]=temp;}
    
    
    
    public  HNode[] readHNode() {return head;}
    
    
    public  HNode search(int k)
        {     
        int index=hash(k);
        HNode temp=head[index];  
        boolean found=false;
        while(temp!=null&&found==false) {
               if (temp.key==k){found=true; break;}
               temp=temp.next;
        }
        return temp;}


}
4

1 に答える 1