|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractMap<K,V> org.jboss.cache.util.DeltaMap<K,V>
K
- key typeV
- value typepublic class DeltaMap<K,V>
Wraps an existing map, which is not modified, reflecting modifications in an internal modification set.
This is to minimize the amount of data copying, for instance in the case few changes are applied. Example usage:HashMap<String, String> hm = new HashMap<String, String>(); hm.put("a", "apple"); DeltaMapdm = DeltaMap.create(hm); dm.remove("a"); assert hm.containsKey("a"); assert !dm.containsKey("a"); dm.commit(); assert !hm.containsKey("a");
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Method Summary | ||
---|---|---|
void |
clear()
|
|
void |
commit()
Commits the changes to the original map. |
|
boolean |
containsKey(Object key)
|
|
static
|
create()
Creates and returns a DeltaMap for an empty map. |
|
static
|
create(Map<K,V> original)
Creates and returns a DeltaMap for an original map. |
|
Set<Map.Entry<K,V>> |
entrySet()
|
|
static
|
excludeKeys(Map<K,V> original,
K... exclude)
Creates and returns a DeltaMap for an original map, excluding some key mappings. |
|
static
|
excludeKeys(Map<K,V> original,
Set<K> exclude)
Creates and returns a DeltaMap for an original map, excluding some key mappings. |
|
V |
get(Object key)
|
|
Map<K,V> |
getChanged()
Returns a Map of the entries changed, not including those removed. |
|
Map<K,V> |
getOriginal()
Returns the original wrapped Map. |
|
Set<K> |
getRemoved()
Returns the entries removed, including entries excluded by the constructor. |
|
boolean |
isModified()
Returns true if the internal map was modified. |
|
V |
put(K key,
V value)
|
|
V |
remove(Object key)
|
|
void |
setOriginal(Map<K,V> original)
Sets the original values of this delta map. |
|
int |
size()
|
|
String |
toDebugString()
Returns a debug string. |
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 |
Method Detail |
---|
public static <K,V> DeltaMap<K,V> create(Map<K,V> original)
original
- will not be modified, except by commit()
public static <K,V> DeltaMap<K,V> create()
public static <K,V> DeltaMap<K,V> excludeKeys(Map<K,V> original, Set<K> exclude)
original
- will not be modified, except by commit()
exclude
- entries not to include
public static <K,V> DeltaMap<K,V> excludeKeys(Map<K,V> original, K... exclude)
public Set<Map.Entry<K,V>> entrySet()
entrySet
in interface Map<K,V>
entrySet
in class AbstractMap<K,V>
public int size()
size
in interface Map<K,V>
size
in class AbstractMap<K,V>
public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
containsKey
in class AbstractMap<K,V>
public V get(Object key)
get
in interface Map<K,V>
get
in class AbstractMap<K,V>
public V put(K key, V value)
put
in interface Map<K,V>
put
in class AbstractMap<K,V>
public V remove(Object key)
remove
in interface Map<K,V>
remove
in class AbstractMap<K,V>
public void commit()
public boolean isModified()
public String toDebugString()
public void clear()
clear
in interface Map<K,V>
clear
in class AbstractMap<K,V>
public Map<K,V> getOriginal()
public void setOriginal(Map<K,V> original)
public Map<K,V> getChanged()
public Set<K> getRemoved()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |