net.cscott.jutil

Class PersistentMap<K,V>

public class PersistentMap<K,V> extends Object implements Serializable

PersistentMap implements a persistent map, based on a persistent randomized treap.

Version: $Id: PersistentMap.java,v 1.2 2004/01/13 01:28:37 cananian Exp $

Author: C. Scott Ananian

Constructor Summary
PersistentMap()
Creates an empty PersistentMap whose key objects will all implement java.lang.Comparable.
PersistentMap(Comparator<K> c)
Creates an empty PersistentMap whose key objects are ordered by the given Comparator.
Method Summary
Map<K,V>asMap()
java.util.Collections view of the mapping.
booleancontainsKey(K key)
Determines if there is a mapping for the given key.
Vget(K key)
Gets the value which key maps to.
inthashCode()
booleanisEmpty()
Determines if this PersistentMap has any mappings.
PersistentMap<K,V>put(K key, V value)
Creates and returns a new PersistantMap identical to this one, except it contains a mapping from key to value.
PersistentMap<K,V>putAll(PersistentMap<K,V> map)
Put all the mappings in the given map into this map, throwing out conflicting mappings from this set as necessary.
PersistentMap<K,V>remove(K key)
Make a new PersistentMap identical to this one, except that it does not contain a mapping for key.
intsize()
Count the number of key->value mappings in this PersistentMap.
StringtoString()
Human-readable representation of the map.

Constructor Detail

PersistentMap

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

PersistentMap

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

Method Detail

asMap

public Map<K,V> asMap()
java.util.Collections view of the mapping.

containsKey

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

get

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

hashCode

public int hashCode()

isEmpty

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

put

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

putAll

public PersistentMap<K,V> putAll(PersistentMap<K,V> map)
Put all the mappings in the given map into this map, throwing out conflicting mappings from this set as necessary.

remove

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

size

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

toString

public String toString()
Human-readable representation of the map.
Copyright © 2003 C. Scott Ananian