以下是该类的实现方式,然后我有了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];
}