Package dsa
Interface BasicST<K,V>
- Type Parameters:
K
- the type of keys in the symbol table.V
- the type of values in the symbol table.
- All Known Implementing Classes:
LinearSearchST
,SeparateChainingHashST
public interface BasicST<K,V>
This interface specifies the API for the basic symbol table data structure.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if this symbol table containskey
, andfalse
otherwise.void
Deleteskey
and the associated value from this symbol table.Returns the value associated withkey
in this symbol table, ornull
.boolean
isEmpty()
Returnstrue
if this symbol table is empty, andfalse
otherwise.keys()
Returns all the keys in this symbol table.void
Inserts thekey
andvalue
pair into this symbol table.int
size()
Returns the number of key-value pairs in this symbol table.toString()
Returns a string representation of this symbol table.
-
Method Details
-
isEmpty
boolean isEmpty()Returnstrue
if this symbol table is empty, andfalse
otherwise.- Returns:
true
if this symbol table is empty, andfalse
otherwise.
-
size
int size()Returns the number of key-value pairs in this symbol table.- Returns:
- the number of key-value pairs in this symbol table.
-
put
Inserts thekey
andvalue
pair into this symbol table.- Parameters:
key
- the key.value
- the value.
-
get
Returns the value associated withkey
in this symbol table, ornull
.- Parameters:
key
- the key.- Returns:
- the value associated with
key
in this symbol table, ornull
.
-
contains
Returnstrue
if this symbol table containskey
, andfalse
otherwise.- Parameters:
key
- the key.- Returns:
true
if this symbol table containskey
, andfalse
otherwise.
-
delete
Deleteskey
and the associated value from this symbol table.- Parameters:
key
- the key.
-
keys
Returns all the keys in this symbol table.- Returns:
- all the keys in this symbol table.
-
toString
String toString()Returns a string representation of this symbol table.
-