Package dsa
Class LinearSearchST<K,V>
java.lang.Object
dsa.LinearSearchST<K,V>
- Type Parameters:
K
- the type of keys in the symbol table.V
- the type of values in the symbol table.
- All Implemented Interfaces:
BasicST<K,
V>
This data type provides an implementation of the basic symbol table (BasicST) API, using a linked-list as the
underlying data structure.
-
Constructor Summary
-
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.static void
Unit tests the data type.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.
-
Constructor Details
-
LinearSearchST
public LinearSearchST()Constructs an empty symbol table.
-
-
Method Details
-
isEmpty
public boolean isEmpty()Returnstrue
if this symbol table is empty, andfalse
otherwise. -
size
public int size()Returns the number of key-value pairs in this symbol table. -
put
Inserts thekey
andvalue
pair into this symbol table. -
get
Returns the value associated withkey
in this symbol table, ornull
. -
contains
Returnstrue
if this symbol table containskey
, andfalse
otherwise. -
delete
Deleteskey
and the associated value from this symbol table. -
keys
Returns all the keys in this symbol table. -
toString
Returns a string representation of this symbol table. -
main
Unit tests the data type.- Parameters:
args
- the command-line arguments.
-