Constructor and Description |
---|
OpenHashMap()
Default constructor uses a hash table with size 23.
|
OpenHashMap(int s)
Constructor receives table size as input.
|
Modifier and Type | Method and Description |
---|---|
V |
get(K k)
Returns the value associated with a given key, throwing a
NoSuchElementException if no value is currently associated
with the given key.
|
V |
remove(K k)
Removes the ordered pair with a given input key k, returning a
NoSuchElementException and leaving the Mapping unchanged if no
such ordered pair exists.
|
void |
set(K k,
V v)
Sets the value associated with an input key to be an input
value — replacing the value formerly associated with
this key if one already exists.
|
public OpenHashMap()
public OpenHashMap(int s)
s
- size of hash table to be usedjava.lang.IllegalArgumentException
- if s is not positivepublic V get(K k) throws java.util.NoSuchElementException
Mapping
get
in interface Mapping<K,V>
k
- the key whose value is to be returnedjava.util.NoSuchElementException
- if no value is defined for this key
public void set(K k, V v)
Mapping
set
in interface Mapping<K,V>
k
- the key for which a value is to be definedv
- the value that is to be defined to this key
public V remove(K k) throws java.util.NoSuchElementException
Mapping
remove
in interface Mapping<K,V>
k
- the key for which a value is to be undefinedjava.util.NoSuchElementException
- if no value was defined for this key