-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMutableLongToRefDictionary.java
More file actions
62 lines (46 loc) · 1.63 KB
/
MutableLongToRefDictionary.java
File metadata and controls
62 lines (46 loc) · 1.63 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
package javasabr.rlib.collections.dictionary;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.LongFunction;
import java.util.function.Supplier;
import javasabr.rlib.collections.dictionary.impl.DefaultMutableHashBasedLongToRefDictionary;
import org.jspecify.annotations.Nullable;
public interface MutableLongToRefDictionary<V> extends LongToRefDictionary<V> {
static <V> MutableLongToRefDictionary<V> ofTypes(Class<V> valueType) {
return new DefaultMutableHashBasedLongToRefDictionary<>();
}
V getOrCompute(long key, Supplier<V> factory);
V getOrCompute(long key, LongFunction<V> factory);
<T> V getOrCompute(long key, T arg1, Function<T, V> factory);
/**
* @return the previous value for the key or null.
*/
@Nullable
V put(long key, V value);
/**
* @return the existing value if the key is already present, or null if the key was absent and the new mapping was added.
*/
@Nullable
V putIfAbsent(long key, V value);
void putAll(LongToRefDictionary<? extends V> dictionary);
MutableLongToRefDictionary<V> append(LongToRefDictionary<? extends V> dictionary);
/**
* @return the optional value of the previous value for the key.
*/
Optional<V> putOptional(long key, V value);
/**
* @return the previous value for the key or null.
*/
@Nullable
V remove(long key);
/**
* @return true if the expectedValue was removed
*/
boolean remove(long key, V expectedValue);
/**
* @return the optional value of the previous value for the key.
*/
Optional<V> removeOptional(long key);
void clear();
LongToRefDictionary<V> toReadOnly();
}