Ois,
Eu gostaria de alterar o método resize()
da classe SeparateChainingHashST
.
O método atual é:
// resize the hash table to have the given number of chains // rehashing all of the keys // // redimensiona a tabela de espalhamento de modo que ela tenha // chains listas ligadas e reinsere todas s chaves private void resize(int chains) { SeparateChainingHashST<Key, Value> temp; temp = new SeparateChainingHashST<Key, Value>(chains); for (int i = 0; i < M; i++) { for (Key key : st[i].keys()) { temp.put(key, st[i].get(key)); } } this.M = temp.M; this.N = temp.N; this.st = temp.st; }
E gostaria de simplificar e escrever
// resize the hash table to have the given number of chains // rehashing all of the keys // // redimensiona a tabela de espalhamento de modo que ela tenha // chains listas ligadas e reinsere todas s chaves private void resize(int chains) { SeparateChainingHashST<Key, Value> temp; temp = new SeparateChainingHashST<Key, Value>(chains); for (int i = 0; i < M; i++) { for (Key key : st[i].keys()) { temp.put(key, st[i].get(key)); } } this = temp; }
Tudo bem?