Package org.mvel2.util
Class SimpleIndexHashMapWrapper<K,V>
java.lang.Object
org.mvel2.util.SimpleIndexHashMapWrapper<K,V>
- All Implemented Interfaces:
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 -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ArrayList
<SimpleIndexHashMapWrapper<K, V>.ValueContainer<K, V>> private int
private final Map
<K, SimpleIndexHashMapWrapper<K, V>.ValueContainer<K, V>> -
Constructor Summary
ConstructorsConstructorDescriptionSimpleIndexHashMapWrapper
(K[] keys) SimpleIndexHashMapWrapper
(K[] keys, int initialCapacity, float load) SimpleIndexHashMapWrapper
(SimpleIndexHashMapWrapper<K, V> wrapper, boolean allocateOnly) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
getByIndex
(int index) getKeyAtIndex
(int index) int
void
initWithKeys
(K[] keys) boolean
isEmpty()
keySet()
void
void
putAtIndex
(int index, V value) int
size()
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
-
Field Details
-
indexCounter
private int indexCounter -
wrappedMap
-
indexBasedLookup
-
-
Constructor Details
-
SimpleIndexHashMapWrapper
public SimpleIndexHashMapWrapper() -
SimpleIndexHashMapWrapper
-
SimpleIndexHashMapWrapper
-
SimpleIndexHashMapWrapper
-
-
Method Details
-
initWithKeys
-
addKey
-
addKey
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V>
-
get
-
getByIndex
-
getKeyAtIndex
-
indexOf
-
put
-
putAtIndex
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-