harpoon.Util.Collections
Class PersistentMap

java.lang.Object
  |
  +--harpoon.Util.Collections.PersistentMap

public class PersistentMap
extends Object

PersistentMap implements a persistent map, based on a binary search tree.

Version:
$Id: PersistentMap.java,v 1.2 2002/02/25 21:09:15 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>

Constructor Summary
PersistentMap()
          Creates an empty PersistentMap whose key objects will all implement java.lang.Comparable.
PersistentMap(Comparator c)
          Creates an empty PersistentMap whose key objects are ordered by the given Comparator.
 
Method Summary
 Map asMap()
          java.util.Collections view of the mapping.
 boolean containsKey(Object key)
          Determines if there is a mapping for the given key.
 Object get(Object key)
          Gets the value which key maps to.
 boolean isEmpty()
          Determines if this PersistentMap has any mappings.
 PersistentMap put(Object key, Object value)
          Creates and returns a new PersistantMap identical to this one, except it contains a mapping from key to value.
 PersistentMap remove(Object key)
          Make a new PersistentMap identical to this one, except that it does not contain a mapping for key.
 int size()
          Count the number of key->value mappings in this PersistentMap.
 String toString()
          Human-readable representation of the map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PersistentMap

public PersistentMap()
Creates an empty PersistentMap whose key objects will all implement java.lang.Comparable.


PersistentMap

public PersistentMap(Comparator c)
Creates an empty PersistentMap whose key objects are ordered by the given Comparator.

Method Detail

isEmpty

public boolean isEmpty()
Determines if this PersistentMap has any mappings.


size

public int size()
Count the number of key->value mappings in this PersistentMap.


put

public PersistentMap put(Object key,
                         Object value)
Creates and returns a new PersistantMap identical to this one, except it contains a mapping from key to value.


get

public Object get(Object key)
Gets the value which key maps to.


containsKey

public boolean containsKey(Object key)
Determines if there is a mapping for the given key.


remove

public PersistentMap remove(Object key)
Make a new PersistentMap identical to this one, except that it does not contain a mapping for key.


toString

public String toString()
Human-readable representation of the map.

Overrides:
toString in class Object

asMap

public Map asMap()
java.util.Collections view of the mapping.