MCPcopy Create free account
hub / github.com/e2wugui/zeze / PMap

Class PMap

ZezeJava/ZezeJava/src/main/java/Zeze/Transaction/Collections/PMap.java:15–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13import org.pcollections.Empty;
14
15public abstract class PMap<K, V> extends Collection implements Map<K, V>, Iterable<Map.Entry<K, V>> {
16 @NotNull org.pcollections.PMap<K, V> map = Empty.map();
17
18 @Override
19 public final @Nullable V get(@NotNull Object key) {
20 return getMap().get(key);
21 }
22
23 @Override
24 public abstract @Nullable V put(@NotNull K key, @NotNull V value);
25
26 @Override
27 public abstract void putAll(@NotNull Map<? extends K, ? extends V> m);
28
29 @Override
30 public abstract @Nullable V remove(@NotNull Object key);
31
32 public abstract boolean remove(@NotNull Map.Entry<K, V> item);
33
34 @Override
35 public abstract void clear();
36
37 public final void copyTo(Map.Entry<K, V> @NotNull [] array, int arrayIndex) {
38 for (var e : getMap().entrySet())
39 array[arrayIndex++] = e;
40 }
41
42 public final @NotNull org.pcollections.PMap<K, V> getMap() {
43 if (isManaged()) {
44 var txn = Transaction.getCurrentVerifyRead(this);
45 if (txn == null)
46 return map;
47 //noinspection DataFlowIssue
48 Log log = txn.getLog(parent().objectId() + variableId());
49 if (log == null)
50 return map;
51 @SuppressWarnings("unchecked")
52 var mapLog = (LogMap1<K, V>)log;
53 return mapLog.getValue();
54 }
55 return map;
56 }
57
58 @Override
59 public final int size() {
60 return getMap().size();
61 }
62
63 @Override
64 public final boolean containsValue(@NotNull Object v) {
65 return getMap().containsValue(v);
66 }
67
68 @Override
69 public final boolean containsKey(@NotNull Object key) {
70 return getMap().containsKey(key);
71 }
72

Callers

nothing calls this directly

Calls 1

mapMethod · 0.45

Tested by

no test coverage detected