Package dsa
Interface BasicST<Key,Value>
-
- All Known Implementing Classes:
LinearSearchST
,SeparateChainingHashST
public interface BasicST<Key,Value>
This interface specifies the API for the basic symbol table data structure.
-
-
Method Summary
All Methods Instance Methods Abstract 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.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.
-
-
-
Method Detail
-
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
void put(Key key, Value value)
Inserts thekey
andvalue
pair into this symbol table.- Parameters:
key
- the key.value
- the value.
-
get
Value get(Key key)
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
boolean contains(Key key)
Returnstrue
if this symbol table containskey
, andfalse
otherwise.- Parameters:
key
- the key.- Returns:
true
if this symbol table containskey
, andfalse
otherwise.
-
delete
void delete(Key key)
Deleteskey
and the associated value from this symbol table.- Parameters:
key
- the key.
-
-