Package org.opendaylight.yangtools.util
Class MutableOffsetMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
org.opendaylight.yangtools.util.MutableOffsetMap<K,V>
- Type Parameters:
K
- the type of keys maintained by this mapV
- the type of mapped values
- All Implemented Interfaces:
Cloneable
,Map<K,
,V> Mutable
,ModifiableMapPhase<K,
V>
public abstract class MutableOffsetMap<K,V>
extends AbstractMap<K,V>
implements Cloneable, ModifiableMapPhase<K,V>
A mutable version of
ImmutableOffsetMap
. It inherits the set of mappings from the immutable version and
allows updating/removing existing mappings. New mappings are stored in a dedicated LinkedHashMap
to preserve
insertion order. It also tracks the need to duplicate the backing array, so the sequence of
ImmutableOffsetMap<K, V> source;
ImmutableOffsetMap<K, V> result = source.createMutableClone().immutableCopy();
results in source and result sharing the backing objects.
This map does not support null keys nor values.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> -
Method Summary
Modifier and TypeMethodDescriptionfinal void
clear()
@NonNull MutableOffsetMap
<K, V> clone()
final boolean
containsKey
(Object key) entrySet()
final boolean
final V
final int
hashCode()
final boolean
isEmpty()
keySet()
static <K,
V> @NonNull MutableOffsetMap <K, V> ordered()
Create an emptyMutableOffsetMap
which has an iteration order matching the insertion order.static <K,
V> @NonNull MutableOffsetMap <K, V> orderedCopyOf
(Map<K, V> map) Create aMutableOffsetMap
of the specified map, retaining its iteration order.final V
final V
final int
size()
Return an isolated unmodifiable version of this map.static <K,
V> @NonNull MutableOffsetMap <K, V> Create an emptyMutableOffsetMap
which has unspecified iteration order.static <K,
V> @NonNull MutableOffsetMap <K, V> unorderedCopyOf
(Map<K, V> map) Create aMutableOffsetMap
of the specified map, potentially with a different iteration order.Methods inherited from class java.util.AbstractMap
containsValue, putAll, toString, values
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsValue, forEach, getOrDefault, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll, values
-
Method Details
-
orderedCopyOf
Create aMutableOffsetMap
of the specified map, retaining its iteration order.- Parameters:
map
- input map- Returns:
- MutableOffsetMap with the same iteration order
- Throws:
NullPointerException
- ifmap
is null
-
unorderedCopyOf
Create aMutableOffsetMap
of the specified map, potentially with a different iteration order.- Parameters:
map
- input map- Returns:
- MutableOffsetMap with undefined iteration order
- Throws:
NullPointerException
- ifmap
is null
-
ordered
Create an emptyMutableOffsetMap
which has an iteration order matching the insertion order.- Returns:
- MutableOffsetMap which preserves insertion order
-
unordered
Create an emptyMutableOffsetMap
which has unspecified iteration order.- Returns:
- An MutableOffsetMap
-
size
public final int size() -
isEmpty
public final boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V> - Overrides:
containsKey
in classAbstractMap<K,
V>
-
get
-
put
-
remove
-
clear
public final void clear() -
entrySet
-
toUnmodifiableMap
Description copied from interface:ModifiableMapPhase
Return an isolated unmodifiable version of this map. Returned object must not allow removal, addition or changing of mappings. Its mappings must match the mappings currently present in this map, but must not be affected by any subsequent changes to this map.- Specified by:
toUnmodifiableMap
in interfaceModifiableMapPhase<K,
V> - Returns:
- An unmodifiable version of this map.
-
clone
- Overrides:
clone
in classAbstractMap<K,
V>
-
hashCode
public final int hashCode() -
equals
-
keySet
-