Package org.mvel2.util
Class SimpleIndexHashMapWrapper<K,V>
- java.lang.Object
-
- org.mvel2.util.SimpleIndexHashMapWrapper<K,V>
-
- All Implemented Interfaces:
Map<K,V>
public class SimpleIndexHashMapWrapper<K,V> extends Object implements Map<K,V>
As most use-cases of the VariableResolverFactory's rely on Maps, this is meant to implement a simple wrapper which records index positions for use by the optimizing facilities. This wrapper also ensures that the Map is only additive. You cannot remove an element once it's been added. While this may seem like an odd limitation, it is consistent with the language semantics. (ie. it's not possible to delete a variable at runtime once it's been declared).- Author:
- Mike Brock
-
-
Constructor Summary
Constructors Constructor Description SimpleIndexHashMapWrapper()SimpleIndexHashMapWrapper(K[] keys)SimpleIndexHashMapWrapper(K[] keys, int initialCapacity, float load)SimpleIndexHashMapWrapper(SimpleIndexHashMapWrapper<K,V> wrapper, boolean allocateOnly)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddKey(K key)voidaddKey(K key, V value)voidclear()booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<K,V>>entrySet()Vget(Object key)VgetByIndex(int index)KgetKeyAtIndex(int index)intindexOf(K key)voidinitWithKeys(K[] keys)booleanisEmpty()Set<K>keySet()Vput(K key, V value)voidputAll(Map<? extends K,? extends V> m)voidputAtIndex(int index, V value)Vremove(Object key)intsize()Collection<V>values()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Constructor Detail
-
SimpleIndexHashMapWrapper
public SimpleIndexHashMapWrapper()
-
SimpleIndexHashMapWrapper
public SimpleIndexHashMapWrapper(SimpleIndexHashMapWrapper<K,V> wrapper, boolean allocateOnly)
-
SimpleIndexHashMapWrapper
public SimpleIndexHashMapWrapper(K[] keys)
-
SimpleIndexHashMapWrapper
public SimpleIndexHashMapWrapper(K[] keys, int initialCapacity, float load)
-
-
Method Detail
-
initWithKeys
public void initWithKeys(K[] keys)
-
addKey
public void addKey(K key)
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<K,V>
-
getByIndex
public V getByIndex(int index)
-
getKeyAtIndex
public K getKeyAtIndex(int index)
-
indexOf
public int indexOf(K key)
-
putAtIndex
public void putAtIndex(int index, V value)
-
-