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

Method put

ZezeJava/ZezeJava/src/main/java/Zeze/Util/IntHashMap.java:175–203  ·  view source on GitHub ↗
(int key, @Nullable V value)

Source from the content-addressed store, hash-verified

173 }
174
175 public @Nullable V put(int key, @Nullable V value) {
176 if (key == 0) {
177 final V oldV = zeroValue;
178 zeroValue = value;
179 if (!hasZeroValue) {
180 hasZeroValue = true;
181 size++;
182 }
183 return oldV;
184 }
185 final int[] kt = keyTable;
186 final V[] vt = valueTable;
187 final int m = mask;
188 for (int i = hash(key); ; i = (i + 1) & m) {
189 final int k = kt[i];
190 if (k == 0) {
191 kt[i] = key;
192 vt[i] = value;
193 if (++size >= threshold)
194 resize(kt.length << 1);
195 return null;
196 }
197 if (k == key) {
198 final V oldV = vt[i];
199 vt[i] = value;
200 return oldV;
201 }
202 }
203 }
204
205 public void putAll(@NotNull IntHashMap<? extends V> map) {
206 if (map.hasZeroValue) {

Callers 4

testIntHashMapMethod · 0.95
groupByServerMethod · 0.95
putAllMethod · 0.95
groupByServerIdMethod · 0.95

Calls 2

hashMethod · 0.95
resizeMethod · 0.95

Tested by 1

testIntHashMapMethod · 0.76