Package dsa
Class LinearSearchST<Key,Value>
- java.lang.Object
-
- dsa.LinearSearchST<Key,Value>
-
-
Constructor Summary
Constructors Constructor Description LinearSearchST()
Constructs an empty symbol table.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(Key key)
Returnstrue
if this symbol table containskey
, andfalse
otherwise.void
delete(Key key)
Deleteskey
and the associated value from this symbol table.Value
get(Key key)
Returns the value associated withkey
in this symbol table, ornull
.boolean
isEmpty()
Returnstrue
if this symbol table is empty, andfalse
otherwise.Iterable<Key>
keys()
Returns all the keys in this symbol table.static void
main(String[] args)
Unit tests the data type.void
put(Key key, Value value)
Inserts thekey
andvalue
pair into this symbol table.int
size()
Returns the number of key-value pairs in this symbol table.String
toString()
Returns a string representation of this symbol table.
-
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
Description copied from interface:BasicST
Returnstrue
if this symbol table is empty, andfalse
otherwise.
-
size
public int size()
Description copied from interface:BasicST
Returns the number of key-value pairs in this symbol table.
-
put
public void put(Key key, Value value)
Description copied from interface:BasicST
Inserts thekey
andvalue
pair into this symbol table.
-
get
public Value get(Key key)
Description copied from interface:BasicST
Returns the value associated withkey
in this symbol table, ornull
.
-
contains
public boolean contains(Key key)
Description copied from interface:BasicST
Returnstrue
if this symbol table containskey
, andfalse
otherwise.
-
delete
public void delete(Key key)
Description copied from interface:BasicST
Deleteskey
and the associated value from this symbol table.
-
keys
public Iterable<Key> keys()
Description copied from interface:BasicST
Returns all the keys in this symbol table.
-
toString
public String toString()
Returns a string representation of this symbol table.
-
main
public static void main(String[] args)
Unit tests the data type.- Parameters:
args
- the command-line arguments.
-
-