harpoon.Util.Collections
Class HashEnvironment

java.lang.Object
  |
  +--java.util.AbstractMap
        |
        +--harpoon.Util.Collections.HashEnvironment
All Implemented Interfaces:
Environment, Map

public class HashEnvironment
extends AbstractMap
implements Environment

A HashEnvironment is an Environment using a HashMap as the backing store.

Version:
$Id: HashEnvironment.java,v 1.3 2002/02/26 22:47:37 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>

Nested Class Summary
 
Nested classes inherited from class harpoon.Util.Collections.Environment
Environment.Mark
 
Nested classes inherited from class java.util.Map
Map.Entry
 
Constructor Summary
HashEnvironment()
          Creates a HashEnvironment.
HashEnvironment(Map m)
          Creates a HashEnvironment with all the mappings in the given map.
 
Method Summary
 void clear()
          Clears all mappings.
 boolean containsKey(Object key)
          Returns true if this map contains a mapping for the specified key.
 Set entrySet()
          The Set returned by this method is really a MapSet.
 Object get(Object key)
          Returns the value to which this map maps the specified key.
 Environment.Mark getMark()
          Get a mark that will allow you to restore the current state of this environment.
static void main(String[] argv)
          Self-test function.
 Object put(Object key, Object value)
          Associates the specified value with the specified key in this map.
 Object remove(Object key)
          Removes the mapping for this key from this map if present.
 int size()
          Returns the number of key-value mappings in this map.
 void undoToMark(Environment.Mark m)
          Undo all changes since the supplied mark, restoring the map to its state at the time the mark was taken.
 
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsValue, equals, hashCode, isEmpty, keySet, putAll, values
 

Constructor Detail

HashEnvironment

public HashEnvironment()
Creates a HashEnvironment.


HashEnvironment

public HashEnvironment(Map m)
Creates a HashEnvironment with all the mappings in the given map.

Method Detail

containsKey

public boolean containsKey(Object key)
Returns true if this map contains a mapping for the specified key.

Specified by:
containsKey in interface Map
Overrides:
containsKey in class AbstractMap

get

public Object get(Object key)
Returns the value to which this map maps the specified key.

Specified by:
get in interface Map
Overrides:
get in class AbstractMap

put

public Object put(Object key,
                  Object value)
Associates the specified value with the specified key in this map.

Specified by:
put in interface Map
Overrides:
put in class AbstractMap

remove

public Object remove(Object key)
Removes the mapping for this key from this map if present.

Specified by:
remove in interface Map
Overrides:
remove in class AbstractMap

size

public int size()
Returns the number of key-value mappings in this map.

Specified by:
size in interface Map
Overrides:
size in class AbstractMap

clear

public void clear()
Clears all mappings.

Specified by:
clear in interface Map
Overrides:
clear in class AbstractMap

getMark

public Environment.Mark getMark()
Description copied from interface: Environment
Get a mark that will allow you to restore the current state of this environment.

Specified by:
getMark in interface Environment

undoToMark

public void undoToMark(Environment.Mark m)
Description copied from interface: Environment
Undo all changes since the supplied mark, restoring the map to its state at the time the mark was taken. The undoToMark() operation must be repeatable.

Specified by:
undoToMark in interface Environment

entrySet

public Set entrySet()
The Set returned by this method is really a MapSet.

Specified by:
entrySet in interface Map
Specified by:
entrySet in class AbstractMap

main

public static void main(String[] argv)
Self-test function.