Download Jar. Libraryless. Click here for Pure Java version (4042L/23K).
1 | !7 |
2 | |
3 | sclass X { |
4 | S value; |
5 | |
6 | *() {} |
7 | *(S *value) {} |
8 | } |
9 | |
10 | p { |
11 | Hasher<X> hasher = new Hasher<X>() { |
12 | public int hashCode(X o) { ret _hashCode(o.value); } |
13 | public bool equals(X a, X b) { ret a == null ? b == null : b != null && eq(a.value, b.value); } |
14 | }; |
15 | |
16 | WeakHasherMap<X, Bool> map = new(hasher); |
17 | X x1 = X("hello"); |
18 | map.put(x1, true); |
19 | gc(); |
20 | assertTrue(map.get(new X("hello"))); |
21 | assertNull(map.get(new X("world"))); |
22 | |
23 | assertSame(x1, map.findKey(new X("hello"))); |
24 | assertNull(map.findKey(new X("world"))); |
25 | |
26 | print("OK"); |
27 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1012714 |
Snippet name: | Test WeakHasherMap (OK) |
Eternal ID of this version: | #1012714/8 |
Text MD5: | 8ee9376879dbdd0c799e0a1b3d98c26b |
Transpilation MD5: | 8fefb081a0cc18c4a5c57d37b942a7dc |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-12-10 21:44:44 |
Source code size: | 576 bytes / 27 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 533 / 1245 |
Version history: | 7 change(s) |
Referenced in: | [show references] |