【发布时间】:2015-05-15 17:57:37
【问题描述】:
我有一个分配,我应该在其中创建一个双向哈希表。 我应该为双向哈希表制作一个构造函数,但我完全不知道如何制作一个,因为我通常不使用一个。 谁能给我一个关于我应该做什么的提示?就像我应该使用构造函数来存储我可以对 hashTable 执行的所有可能操作?
代码如下:
public class BidirectionalHashtable<K, V> {
/**
* construtor
*/
public BidirectionalHashtable() {
}
/**
* returns a value, gets the corresponding key
* @param value - the value
* @return K - the key
*/
public K getKey(V value) {
return null;
}
/**
* receives a key, gets the corresponding value
* @param key - key
* @return V - value
*/
public V getValue(K key) {
return null;
}
还有其他一些方法,例如 put()、containValue() 等
【问题讨论】:
标签: java generics hash constructor hashtable