私はハッシュマップデータ構造を構築することに取り組んでいる宿題に取り組んでいます。私は与えられたコード行を理解していません。次のようにプログラムでは、変数が開始されます。ハッシュマップデータ構造を理解しようとしています
private Map<K,V>[] buckets;
私はハッシュマップで使用されるときバケットの概念が何であるかを知っているが、どのように私はバケットを作成するマップ配列を使用することができますか?このコードを見ると、ハッシュマップの配列を作成する必要があるようですが、それはまったく意味がありません。
さらに詳しい情報が必要な場合は、私に知らせてください。
ご協力いただきまして誠にありがとうございます。
以下は、提供されたコードです。
package cs2321;
import net.datastructures.*;
public class HashMap<K, V> implements Map<K, V> {
private Map<K,V>[] buckets;
protected final int mDefaultHashSize = 1021;
/**
* Constructor that takes a hash size
* @param hashsize The number of buckets to initialize
* in the HashMap
*/
public HashMap(int hashsize){
// TODO: Be sure to initialize the bucket array
// using the hashsize given as the number of buckets
}
public HashMap(){
// TODO: Be sure to initialize the bucket array
// using the default hash size provided.
}
public Iterable<Entry<K, V>> entrySet() {
// TODO Auto-generated method stub
return null;
}
public V get(K key) throws InvalidKeyException {
// TODO Auto-generated method stub
return null;
}
public boolean isEmpty() {
// TODO Auto-generated method stub
return false;
}
public Iterable<K> keySet() {
// TODO Auto-generated method stub
return null;
}
public V put(K key, V value) throws InvalidKeyException {
// TODO Auto-generated method stub
return null;
}
public V remove(K key) throws InvalidKeyException {
// TODO Auto-generated method stub
return null;
}
public int size() {
// TODO Auto-generated method stub
return 0;
}
public Iterable<V> values() {
// TODO Auto-generated method stub
return null;
}
}
、。通常、バケットはリンクされたリストを使用して実装されます。 –