public class BSTDictionary<K extends java.lang.Comparable<K>,V> extends java.lang.Object implements Dictionary<K,V>
Constructor and Description |
---|
BSTDictionary()
Constructs an empty BSTDictionary
Preconditions: None Postcondition: An empty BSTDictionary (satisfying the above BSTDictionary Invariant) has been created. |
Modifier and Type | Method and Description |
---|---|
void |
change(K k,
V v,
cpsc331.collections.BSTDictionary.BSTNode x) |
V |
get(K key)
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 BSTDictionary()
public V get(K key) throws java.util.NoSuchElementException
Mapping
get
in interface Mapping<K extends java.lang.Comparable<K>,V>
key
- 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 extends java.lang.Comparable<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 extends java.lang.Comparable<K>,V>
k
- the key for which a value is to be undefinedjava.util.NoSuchElementException
- if no value was defined for this key