我该如何调整此哈希表的大小?

时间:2016-06-09 17:42:36

标签: java hashtable

以下是该类的实现方式,然后我有了resize函数,我创建了一个新数组,但我不知道从那里去哪里。

private int N;                                // number of strings
private int M;                                // hash table size
private Node[] st;                            // array of linked-lists

private class Node {
    String key;
    Node next;

    public Node(String s) {
        key = s;
    }

    public Node(String s, Node n) {
        this(s);
        next = n;
    }
}

// resize the hash table to have the given number of chains b rehashing all of the keys
private void resize(int newM) {
    // TODO
    Node[] temp = (Node[]) new Node[newM];



}

0 个答案:

没有答案