Package org.optaplanner.core.impl.util
Class FieldBasedScalingMap<K,V>
- java.lang.Object
-
- org.optaplanner.core.impl.util.FieldBasedScalingMap<K,V>
-
- All Implemented Interfaces:
Map<K,V>
public final class FieldBasedScalingMap<K,V> extends Object implements Map<K,V>
Uses a givenMapas storage unless it is the first and only entry, in which case it uses fields. This helps avoid the overhead of creating and accessing a hash map if we only have 1 entry. This implementation is not thread-safe, regardless of the underlyingMap. Iteration order of elements is specified by the underlyingMap.
-
-
Constructor Summary
Constructors Constructor Description FieldBasedScalingMap(Supplier<Map<K,V>> mapSupplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<K,V>>entrySet()As defined byMap.entrySet().voidforEach(BiConsumer<? super K,? super V> action)Vget(Object key)booleanisEmpty()Set<K>keySet()As defined byMap.keySet().Vput(K key, V value)voidputAll(Map<? extends K,? extends V> m)Vremove(Object key)intsize()StringtoString()Collection<V>values()As defined byMap.values().-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
keySet
public Set<K> keySet()
As defined byMap.keySet(). May throw an exception if the iterator is used to remove an element while the map is based on a field.
-
values
public Collection<V> values()
As defined byMap.values(). May throw an exception if the iterator is used to remove an element while the map is based on a field.
-
entrySet
public Set<Map.Entry<K,V>> entrySet()
As defined byMap.entrySet(). May throw an exception if the iterator is used to remove an element while the map is based on a field.
-
forEach
public void forEach(BiConsumer<? super K,? super V> action)
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<K,V>
-
-