Download Jar. Libraryless. Click here for Pure Java version (1846L/12K).
!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); } }; CustomCompactHashSet<X> set = new(hasher); X x1 = X("hello"); set.add(x1); assertTrue(set.contains(new X("hello"))); assertFalse(set.contains(new X("world"))); assertSame(x1, set.find(new X("hello"))); assertNull(set.find(new X("world"))); set.remove(x1); assertNull(set.find(new X("hello"))); print("OK"); }
Began life as a copy of #1012714
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1013079 |
Snippet name: | Test CustomCompactHashSet (OK, but should test more elements) |
Eternal ID of this version: | #1013079/6 |
Text MD5: | 258ff665a7afbccb574d9f6fc0763699 |
Transpilation MD5: | 615dea81daa11b670004678d0c53ef37 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-12-24 20:44:39 |
Source code size: | 631 bytes / 29 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 454 / 1038 |
Version history: | 5 change(s) |
Referenced in: | -