Site Search:

sixth leaf

Back>
public class SeparateChainingHashST<Key, Value> {
    private int N;
    private int M;
    private SequentialSearchST<Key, Value>[] st;
    public SeparateChainingHashST() {this(997);}
    public SeparateChainingHashST(int M) {
        this.M = M;
        st = (SequentialSearchST<Key, Value>[]) new SequentialSearchST[M];
        for(int i = 0; i < M; i++)
            st[i] = new SequentialSearchST();
    }
    
    private int hash(Key key) {//禅
        return (key.hashCode() & 0xfffffff) % M;//気,치, adrenaline
    }

    public Value get(Key key) { return (Value) st[hash(key)].get(key);}

    public void put(Key key, Value val) { st[has(key)].put(key, val); }
}