Package org.mvel2.util
Class SimpleIndexHashMapWrapper<K,V>
- java.lang.Object
-
- org.mvel2.util.SimpleIndexHashMapWrapper<K,V>
-
- All Implemented Interfaces:
java.util.Map<K,V>
public class SimpleIndexHashMapWrapper<K,V> extends java.lang.Object implements java.util.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).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
SimpleIndexHashMapWrapper.ValueContainer<K,V>
-
Field Summary
Fields Modifier and Type Field Description private java.util.ArrayList<SimpleIndexHashMapWrapper.ValueContainer<K,V>>
indexBasedLookup
private int
indexCounter
private java.util.Map<K,SimpleIndexHashMapWrapper.ValueContainer<K,V>>
wrappedMap
-
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 void
addKey(K key)
void
addKey(K key, V value)
void
clear()
boolean
containsKey(java.lang.Object key)
boolean
containsValue(java.lang.Object value)
java.util.Set<java.util.Map.Entry<K,V>>
entrySet()
V
get(java.lang.Object key)
V
getByIndex(int index)
K
getKeyAtIndex(int index)
int
indexOf(K key)
void
initWithKeys(K[] keys)
boolean
isEmpty()
java.util.Set<K>
keySet()
V
put(K key, V value)
void
putAll(java.util.Map<? extends K,? extends V> m)
void
putAtIndex(int index, V value)
V
remove(java.lang.Object key)
int
size()
java.util.Collection<V>
values()
-
-
-
Field Detail
-
indexCounter
private int indexCounter
-
wrappedMap
private final java.util.Map<K,SimpleIndexHashMapWrapper.ValueContainer<K,V>> wrappedMap
-
indexBasedLookup
private final java.util.ArrayList<SimpleIndexHashMapWrapper.ValueContainer<K,V>> indexBasedLookup
-
-
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(java.lang.Object key)
-
containsValue
public boolean containsValue(java.lang.Object value)
-
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)
-
values
public java.util.Collection<V> values()
-
-