Download Jar. Libraryless. Click here for Pure Java version (1846L/12K).
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 | CustomCompactHashSet<X> set = new(hasher); |
17 | X x1 = X("hello"); |
18 | set.add(x1); |
19 | assertTrue(set.contains(new X("hello"))); |
20 | assertFalse(set.contains(new X("world"))); |
21 | |
22 | assertSame(x1, set.find(new X("hello"))); |
23 | assertNull(set.find(new X("world"))); |
24 | |
25 | set.remove(x1); |
26 | assertNull(set.find(new X("hello"))); |
27 | |
28 | print("OK"); |
29 | } |
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: | 455 / 1041 |
Version history: | 5 change(s) |
Referenced in: | [show references] |