mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-81 make it clear that mapForKey is read only as it uses a Function and updateForKey is read/write and takes a mutator.
This commit is contained in:
@@ -345,8 +345,6 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, KI>,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
enum LockType {READ_LOCK, WRITE_LOCK}
|
||||
|
||||
@Override
|
||||
@@ -375,6 +373,14 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, KI>,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R> R updateForKey(K key, @NotNull Mutator<? super V, R> mutator) {
|
||||
try (Context<K, V> entry = lookupUsing(key, null,
|
||||
LockType.WRITE_LOCK, false)) {
|
||||
return mutator.update(entry.value());
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public WriteContext<K, V> acquireUsingLocked(@NotNull K key, @NotNull V usingValue) {
|
||||
@@ -1102,7 +1108,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, KI>,
|
||||
|
||||
/**
|
||||
* Removes a key (or key-value pair) from the Segment.
|
||||
*
|
||||
* <p/>
|
||||
* <p>The entry will only be removed if {@code expectedValue} equals to {@code null} or the value
|
||||
* previously corresponding to the specified key.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user