Class HashState

java.lang.Object
edu.uky.ai.logic.HashState
All Implemented Interfaces:
MutableState, State, Cloneable, Iterable<Atom>

public class HashState extends Object implements MutableState
An implementation of MutableState that uses a HashMap to keep track of which atoms are true.
Author:
Stephen G. Ware
  • Constructor Details

    • HashState

      public HashState()
      Constructs a new state in which no atoms are true.
    • HashState

      public HashState(HashState toClone)
      Constructs a new state which has exactly the same true atoms as a given HashState.
      Parameters:
      toClone - the state to copy
    • HashState

      public HashState(State toClone)
      Constructs a new state which has exactly the same true atoms as a given State.
      Parameters:
      toClone - the state to copy
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • clone

      public HashState clone()
      Overrides:
      clone in class Object
    • iterator

      public Iterator<Atom> iterator()
      Specified by:
      iterator in interface Iterable<Atom>
    • contains

      public boolean contains(Atom atom)
      Description copied from interface: State
      Check whether or not an atom is true in this state.
      Specified by:
      contains in interface State
      Parameters:
      atom - the atom whose truth value will be checked
      Returns:
      true if the atom is true in this state, false otherwise
    • add

      public void add(Atom atom)
      Description copied from interface: MutableState
      Makes a new atom true in this state.
      Specified by:
      add in interface MutableState
      Parameters:
      atom - the atom to make true
    • remove

      public void remove(Atom atom)
      Description copied from interface: MutableState
      Makes a new atom false in this state.
      Specified by:
      remove in interface MutableState
      Parameters:
      atom - the atom to make false