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