## edu.stanford.nlp.util
Class DeltaMap<K,V>

    java.lang.Object
      java.util.AbstractMap<K,V>
          edu.stanford.nlp.util.DeltaMap<K,V>

All Implemented Interfaces:
  Map<K,V>

    public class DeltaMap<K,V>

extends AbstractMap<K,V>

A Map which wraps an original Map, and only stores the changes (deltas) from the original Map. This increases Map access time (roughly doubles it) but eliminates Map creation time and decreases memory usage (if you're keeping the original Map in memory anyway).

Author:
  Teg Grenager (grenager@cs.stanford.edu)

Nested Class Summary

Nested classes/interfaces inherited from class java.util.AbstractMap
`AbstractMap.SimpleImmutableEntry<K,V>`

Nested classes/interfaces inherited from interface java.util.Map
`Map.Entry<K,V>`

Constructor Summary
`DeltaMap(Map<K,V> originalMap)`
`DeltaMap(Map<K,V> originalMap, MapFactory<K,V> mf)` This is very cheap.

Method Summary
`void` `clear()` This is more expensive than normal.
`boolean` `containsKey(Object key)` This is more expensive.
`Set<Map.Entry<K,V>>` `entrySet()` This is cheap.
`V` `get(Object key)` This may cost twice what it would in the original Map.
`static void` `main(String[] args)` For testing only.
`V` `put(K key, V value)` This may cost twice what it would in the original Map because we have to find the original value for this key.
`V` `remove(Object key)`

Methods inherited from class java.util.AbstractMap
`clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, size, toString, values`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### DeltaMap

    public DeltaMap(Map<K,V> originalMap,
                    MapFactory<K,V> mf)

  This is very cheap.

  Parameters:
    `originalMap` - will serve as the basis for this DeltaMap

### DeltaMap

    public DeltaMap(Map<K,V> originalMap)

Method Detail

### containsKey

    public boolean containsKey(Object key)

  This is more expensive.

  Specified by:
    `containsKey` in interface `Map<K,V>`
  Overrides:
    `containsKey` in class `AbstractMap<K,V>`
  Parameters:
    `key` - key whose presence in this map is to be tested.
  Returns:
    `true` if this map contains a mapping for the specified key.

### get

    public V get(Object key)

  This may cost twice what it would in the original Map.

  Specified by:
    `get` in interface `Map<K,V>`
  Overrides:
    `get` in class `AbstractMap<K,V>`
  Parameters:
    `key` - key whose associated value is to be returned.
  Returns:
    the value to which this map maps the specified key, or `null` if the map contains no mapping for this key.

### put

    public V put(K key,
                 V value)

  This may cost twice what it would in the original Map because we have to find the original value for this key.

  Specified by:
    `put` in interface `Map<K,V>`
  Overrides:
    `put` in class `AbstractMap<K,V>`
  Parameters:
    `key` - key with which the specified value is to be associated.
    `value` - value to be associated with the specified key.
  Returns:
    previous value associated with specified key, or `null` if there was no mapping for key. A `null` return can also indicate that the map previously associated `null` with the specified key, if the implementation supports `null` values.

### remove

    public V remove(Object key)

  Specified by:
    `remove` in interface `Map<K,V>`
  Overrides:
    `remove` in class `AbstractMap<K,V>`

### clear

    public void clear()

  This is more expensive than normal.

  Specified by:
    `clear` in interface `Map<K,V>`
  Overrides:
    `clear` in class `AbstractMap<K,V>`

### entrySet

    public Set<Map.Entry<K,V>> entrySet()

  This is cheap.

  Specified by:
    `entrySet` in interface `Map<K,V>`
  Specified by:
    `entrySet` in class `AbstractMap<K,V>`
  Returns:
    a set view of the mappings contained in this map.

### main

    public static void main(String[] args)

  For testing only.

  Parameters:
    `args` - from command line

Stanford NLP Group