public class ChainHashTable<K,V>
extends java.lang.Object
Constructor and Description |
---|
ChainHashTable(int t)
Creates an empty hash table.
|
Modifier and Type | Method and Description |
---|---|
boolean |
defined(K k)
Reports whether a value for a given key k is defined.
|
V |
remove(K k)
Sets the value for a given key to be undefined.
|
V |
search(K k)
Searches for the value associated with a given key, throwing an exception
if no such value is defined.
|
void |
set(K k,
V v)
Sets the value associated with an input key k to be an input value v.
|
public ChainHashTable(int t) throws java.lang.IllegalArgumentException
t
- the table size to be usedjava.lang.IllegalArgumentException
- if the input table size is not positive
public V search(K k) throws java.util.NoSuchElementException
k
- the key whose value is being checked forjava.util.NoSuchElementException
- if no value for this key is defined
public boolean defined(K k)
k
- a key of type kpublic void set(K k, V v)
k
- the value for which a new value is to be definedv
- the value to be associated with this key
public V remove(K k) throws java.util.NoSuchElementException
k
- the key for which no value should be definedjava.util.NoSuchElementException
- if no value was defined for this key