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 Type
    Method
    Description
    boolean
    contains(K key)
    Returns true if this symbol table contains key, and false otherwise.
    void
    delete(K key)
    Deletes key and the associated value from this symbol table.
    get(K key)
    Returns the value associated with key in this symbol table, or null.
    boolean
    Returns true if this symbol table is empty, and false otherwise.
    Returns all the keys in this symbol table.
    void
    put(K key, V value)
    Inserts the key and value pair into this symbol table.
    int
    Returns the number of key-value pairs in this symbol table.
    Returns a string representation of this symbol table.
  • Method Details

    • isEmpty

      boolean isEmpty()
      Returns true if this symbol table is empty, and false otherwise.
      Returns:
      true if this symbol table is empty, and false 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(K key, V value)
      Inserts the key and value pair into this symbol table.
      Parameters:
      key - the key.
      value - the value.
    • get

      V get(K key)
      Returns the value associated with key in this symbol table, or null.
      Parameters:
      key - the key.
      Returns:
      the value associated with key in this symbol table, or null.
    • contains

      boolean contains(K key)
      Returns true if this symbol table contains key, and false otherwise.
      Parameters:
      key - the key.
      Returns:
      true if this symbol table contains key, and false otherwise.
    • delete

      void delete(K key)
      Deletes key and the associated value from this symbol table.
      Parameters:
      key - the key.
    • keys

      Iterable<K> 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.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this symbol table.