-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMutableRefToRefDictionary.java
More file actions
63 lines (47 loc) · 1.62 KB
/
MutableRefToRefDictionary.java
File metadata and controls
63 lines (47 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package javasabr.rlib.collections.dictionary;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
import javasabr.rlib.collections.dictionary.impl.DefaultMutableHashBasedRefToRefDictionary;
import org.jspecify.annotations.Nullable;
public interface MutableRefToRefDictionary<K, V> extends RefToRefDictionary<K, V> {
static <K, V> MutableRefToRefDictionary<K, V> ofTypes(
Class<K> keyType,
Class<V> valueType) {
return new DefaultMutableHashBasedRefToRefDictionary<>();
}
V getOrCompute(K key, Supplier<V> factory);
V getOrCompute(K key, Function<K, V> factory);
<T> V getOrCompute(K key, T arg1, Function<T, V> factory);
/**
* @return the previous value for the key or null.
*/
@Nullable
V put(K key, V value);
/**
* @return the previous value associated with the specified key, or null if there was no mapping for the key.
*/
@Nullable
V putIfAbsent(K key, V value);
void putAll(RefToRefDictionary<? extends K, ? extends V> dictionary);
MutableRefToRefDictionary<K, V> append(RefToRefDictionary<? extends K, ? extends V> dictionary);
/**
* @return the optional value of the previous value for the key.
*/
Optional<V> putOptional(K key, V value);
/**
* @return the previous value for the key or null.
*/
@Nullable
V remove(K key);
/**
* @return true if the expectedValue was removed
*/
boolean remove(K key, V expectedValue);
/**
* @return the optional value of the previous value for the key.
*/
Optional<V> removeOptional(K key);
void clear();
RefToRefDictionary<K, V> toReadOnly();
}