Package dsa

Class LinearSearchST<Key,​Value>

  • All Implemented Interfaces:
    BasicST<Key,​Value>

    public class LinearSearchST<Key,​Value>
    extends Object
    implements BasicST<Key,​Value>
    This data type provides an implementation of the basic symbol table (BasicST) API, using a linked-list as the underlying data structure.
    • Constructor Detail

      • LinearSearchST

        public LinearSearchST()
        Constructs an empty symbol table.
    • Method Detail

      • isEmpty

        public boolean isEmpty()
        Description copied from interface: BasicST
        Returns true if this symbol table is empty, and false otherwise.
        Specified by:
        isEmpty in interface BasicST<Key,​Value>
        Returns:
        true if this symbol table is empty, and false otherwise.
      • size

        public int size()
        Description copied from interface: BasicST
        Returns the number of key-value pairs in this symbol table.
        Specified by:
        size in interface BasicST<Key,​Value>
        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 the key and value pair into this symbol table.
        Specified by:
        put in interface BasicST<Key,​Value>
        Parameters:
        key - the key.
        value - the value.
      • get

        public Value get​(Key key)
        Description copied from interface: BasicST
        Returns the value associated with key in this symbol table, or null.
        Specified by:
        get in interface BasicST<Key,​Value>
        Parameters:
        key - the key.
        Returns:
        the value associated with key in this symbol table, or null.
      • contains

        public boolean contains​(Key key)
        Description copied from interface: BasicST
        Returns true if this symbol table contains key, and false otherwise.
        Specified by:
        contains in interface BasicST<Key,​Value>
        Parameters:
        key - the key.
        Returns:
        true if this symbol table contains key, and false otherwise.
      • delete

        public void delete​(Key key)
        Description copied from interface: BasicST
        Deletes key and the associated value from this symbol table.
        Specified by:
        delete in interface BasicST<Key,​Value>
        Parameters:
        key - the key.
      • keys

        public Iterable<Key> keys()
        Description copied from interface: BasicST
        Returns all the keys in this symbol table.
        Specified by:
        keys in interface BasicST<Key,​Value>
        Returns:
        all the keys in this symbol table.
      • toString

        public String toString()
        Returns a string representation of this symbol table.
        Overrides:
        toString in class Object
        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.