rails.game.state
Class HashMapState<K,V>

java.lang.Object
  extended by rails.game.state.HashMapState<K,V>

public class HashMapState<K,V>
extends java.lang.Object

State class that wraps a HashMap Generates according map moves Remark: Does not extend State or implements StateI do avoid additional overhead All state/move mechanisms already contained in Move objects For the future a simpler unified StateI would make things clearer TODO: Replace all stateful HashMaps by this class and simplify according move objects


Constructor Summary
HashMapState(java.lang.String listName)
          constructor for an empty map
HashMapState(java.lang.String listName, java.util.Map<K,V> map)
          constructor for a prefilled map
 
Method Summary
 void clear()
           
 V get(K key)
           
 void initFromMap(java.util.Map<K,V> initMap)
          (re)intializes the state map from another map efficiently generates the required moves
 boolean isEmpty()
           
 void put(K key, V value)
           
 void putAll(java.util.Map<K,V> map)
           
 void remove(K key)
           
 java.util.Set<K> viewKeySet()
           
 java.util.Map<K,V> viewMap()
           
 java.util.Collection<V> viewValues()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashMapState

public HashMapState(java.lang.String listName)
constructor for an empty map


HashMapState

public HashMapState(java.lang.String listName,
                    java.util.Map<K,V> map)
constructor for a prefilled map

Method Detail

put

public void put(K key,
                V value)

putAll

public void putAll(java.util.Map<K,V> map)

get

public V get(K key)

remove

public void remove(K key)

clear

public void clear()

initFromMap

public void initFromMap(java.util.Map<K,V> initMap)
(re)intializes the state map from another map efficiently generates the required moves


viewMap

public java.util.Map<K,V> viewMap()
Returns:
unmodifiable view of map

viewKeySet

public java.util.Set<K> viewKeySet()
Returns:
unmodifiable view of keyset

viewValues

public java.util.Collection<V> viewValues()

isEmpty

public boolean isEmpty()