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

Method add

ZezeJava/ZezeJava/src/main/java/Zeze/Util/LongHashSet.java:89–109  ·  view source on GitHub ↗
(long key)

Source from the content-addressed store, hash-verified

87 }
88
89 public boolean add(long key) {
90 if (key == 0) {
91 if (hasZeroKey)
92 return false;
93 hasZeroKey = true;
94 size++;
95 return true;
96 }
97 long[] kt = keyTable;
98 for (int i = hash(key), m = kt.length - 1; ; i = (i + 1) & m) {
99 long k = kt[i];
100 if (k == 0) {
101 kt[i] = key;
102 if (++size >= threshold)
103 resize(kt.length << 1);
104 return true;
105 }
106 if (k == key)
107 return false;
108 }
109 }
110
111 public void addAll(@NotNull LongHashSet set) {
112 if (set.hasZeroKey)

Callers 5

testLongHashSetMethod · 0.95
testSimpleMethod · 0.95
addAllMethod · 0.95
sendDirectMethod · 0.95
loadTimerMethod · 0.95

Calls 2

hashMethod · 0.95
resizeMethod · 0.95

Tested by 2

testLongHashSetMethod · 0.76
testSimpleMethod · 0.76