Download Jar. Libraryless. Click here for Pure Java version (4042L/23K).
!7 sclass X { S value; *() {} *(S *value) {} } p { Hasher<X> hasher = new Hasher<X>() { public int hashCode(X o) { ret _hashCode(o.value); } public bool equals(X a, X b) { ret a == null ? b == null : b != null && eq(a.value, b.value); } }; WeakHasherMap<X, Bool> map = new(hasher); X x1 = X("hello"); map.put(x1, true); gc(); assertTrue(map.get(new X("hello"))); assertNull(map.get(new X("world"))); assertSame(x1, map.findKey(new X("hello"))); assertNull(map.findKey(new X("world"))); print("OK"); }
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: | 532 / 1240 |
Version history: | 7 change(s) |
Referenced in: | #1013079 - Test CustomCompactHashSet (OK, but should test more elements) |