gov.llnl.ontology.util
Class ExtendedMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by gov.llnl.ontology.util.ExtendedMap<K,V>
All Implemented Interfaces:
Map<K,V>

public class ExtendedMap<K,V>
extends AbstractMap<K,V>

A Map that extends an existing map without modifying the underlying map. Given an existing Map, this class will provide read only access to the elements in the Map and store all new key, value pairs in a new internal Map.

This class is extremely useful for when several different maps need to share a set of mappings provided by a base map, but duplicate copies of the map cannot be created, due to memory constraints.

Author:
Keith Stevens

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
ExtendedMap(Map<K,V> baseMap)
          Creates a new ExtendedMap that wraps the given Map.
 
Method Summary
 Set<Map.Entry<K,V>> entrySet()
          
 V get(Object key)
          
 V put(K key, V value)
          
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExtendedMap

public ExtendedMap(Map<K,V> baseMap)
Creates a new ExtendedMap that wraps the given Map. All new mappings will be stored in a new map so that baseMap is never modified.

Method Detail

entrySet

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

Specified by:
entrySet in interface Map<K,V>
Specified by:
entrySet in class AbstractMap<K,V>

get

public V get(Object key)

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

put

public V put(K key,
             V value)

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


Copyright © 2010-2011. All Rights Reserved.