ix.util.context
Class ContextHashMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
ix.util.context.ContextHashMap<K,V>
- All Implemented Interfaces:
- ContextMap<K,V>, java.util.Map<K,V>
public class ContextHashMap<K,V>
- extends java.util.AbstractMap<K,V>
- implements ContextMap<K,V>
A context-layered version of HashMap. Properties:
- Entries cannot be removed. The remove() and clear() methods,
and the entry set's remove(), removeAll(), retainAll(), and clear()
methods, are not supported. However, there is a method that
will remove all entries in all contexts:
clearCompletely()
.
- Iterators over the entry-set, key-set, or values return items
in the order in which the keys were first added to the map.
- The entry-set and its iterators must be used in the context
in which the entry-set was created by a call to
entrySet()
.
- Like the java.util classes WeakHashMap and IdentityHashMap,
it is not a subclass of HashMap.
As of I-X 3.3, entires can be removed by calling the remove(Object)
method, but still not in any other way. If a key is removed, then
used again with a put, it regains its original position in the
iteration order. However, the order is forgotten after a
clearCompletely().
As of I-X 4.1, clear() is also supported. It removes all entries
in the current context.
Nested classes/interfaces inherited from class java.util.AbstractMap |
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
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 |
Methods inherited from interface java.util.Map |
containsValue, equals, hashCode, isEmpty, keySet, putAll, size, values |
UNDEF
protected static final java.lang.Object UNDEF
holder
protected ContextHolder holder
map
protected java.util.HashMap map
keyChain
protected ContextHashMap.Entry keyChain
keyChainLast
protected ContextHashMap.Entry keyChainLast
ContextHashMap
public ContextHashMap()
ContextHashMap
public ContextHashMap(int initialCapacity)
ContextHashMap
public ContextHashMap(int initialCapacity,
float loadFactor)
ContextHashMap
public ContextHashMap(java.util.Map m)
ContextHashMap
public ContextHashMap(ContextHolder holder)
ContextHashMap
public ContextHashMap(ContextHolder holder,
java.util.Map m)
put
public V put(K key,
V value)
- Specified by:
put
in interface java.util.Map<K,V>
- Overrides:
put
in class java.util.AbstractMap<K,V>
get
public V get(java.lang.Object key)
- Specified by:
get
in interface java.util.Map<K,V>
- Overrides:
get
in class java.util.AbstractMap<K,V>
entrySet
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
- Specified by:
entrySet
in interface java.util.Map<K,V>
- Specified by:
entrySet
in class java.util.AbstractMap<K,V>
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKey
in interface java.util.Map<K,V>
- Overrides:
containsKey
in class java.util.AbstractMap<K,V>
clearCompletely
public void clearCompletely()
- Remove all entries in all contexts.
- Specified by:
clearCompletely
in interface ContextMap<K,V>
remove
public V remove(java.lang.Object key)
- Specified by:
remove
in interface java.util.Map<K,V>
- Overrides:
remove
in class java.util.AbstractMap<K,V>
clear
public void clear()
- Specified by:
clear
in interface java.util.Map<K,V>
- Overrides:
clear
in class java.util.AbstractMap<K,V>