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)
      Returns true if this symbol table contains key, and false otherwise.
      void delete​(Key key)
      Deletes key and the associated value from this symbol table.
      Value get​(Key key)
      Returns the value associated with key in this symbol table, or null.
      boolean isEmpty()
      Returns true if this symbol table is empty, and false otherwise.
      Iterable<Key> keys()
      Returns all the keys in this symbol table.
      void put​(Key key, Value value)
      Inserts the key and value pair into this symbol table.
      int size()
      Returns the number of key-value pairs in this symbol table.
    • Method Detail

      • 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​(Key key,
                 Value value)
        Inserts the key and value pair into this symbol table.
        Parameters:
        key - the key.
        value - the value.
      • get

        Value get​(Key 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​(Key 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​(Key key)
        Deletes key and the associated value from this symbol table.
        Parameters:
        key - the key.
      • keys

        Iterable<Key> keys()
        Returns all the keys in this symbol table.
        Returns:
        all the keys in this symbol table.