|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.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");
DeltaMap dm = 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 class java.util.AbstractMap |
|---|
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
java.util.Map.Entry<K,V> |
| Method Summary | ||
|---|---|---|
void |
clear()
|
|
void |
commit()
Commits the changes to the original map. |
|
boolean |
containsKey(java.lang.Object key)
|
|
static
|
create()
Creates and returns a DeltaMap for an empty map. |
|
static
|
create(java.util.Map<K,V> original)
Creates and returns a DeltaMap for an original map. |
|
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet()
|
|
static
|
excludeKeys(java.util.Map<K,V> original,
K... exclude)
Creates and returns a DeltaMap for an original map, excluding some key mappings. |
|
static
|
excludeKeys(java.util.Map<K,V> original,
java.util.Set<K> exclude)
Creates and returns a DeltaMap for an original map, excluding some key mappings. |
|
V |
get(java.lang.Object key)
|
|
java.util.Map<K,V> |
getChanged()
Returns a Map of the entries changed, not including those removed. |
|
java.util.Map<K,V> |
getOriginal()
Returns the original wrapped Map. |
|
java.util.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(java.lang.Object key)
|
|
void |
setOriginal(java.util.Map<K,V> original)
Sets the original values of this delta map. |
|
int |
size()
|
|
java.lang.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(java.util.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(java.util.Map<K,V> original,
java.util.Set<K> exclude)
original - will not be modified, except by commit()exclude - entries not to include
public static <K,V> DeltaMap<K,V> excludeKeys(java.util.Map<K,V> original,
K... exclude)
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
entrySet in interface java.util.Map<K,V>entrySet in class java.util.AbstractMap<K,V>public int size()
size in interface java.util.Map<K,V>size in class java.util.AbstractMap<K,V>public boolean containsKey(java.lang.Object key)
containsKey in interface java.util.Map<K,V>containsKey in class java.util.AbstractMap<K,V>public V get(java.lang.Object key)
get in interface java.util.Map<K,V>get in class java.util.AbstractMap<K,V>
public V put(K key,
V value)
put in interface java.util.Map<K,V>put in class java.util.AbstractMap<K,V>public V remove(java.lang.Object key)
remove in interface java.util.Map<K,V>remove in class java.util.AbstractMap<K,V>public void commit()
public boolean isModified()
public java.lang.String toDebugString()
public void clear()
clear in interface java.util.Map<K,V>clear in class java.util.AbstractMap<K,V>public java.util.Map<K,V> getOriginal()
public void setOriginal(java.util.Map<K,V> original)
public java.util.Map<K,V> getChanged()
public java.util.Set<K> getRemoved()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||