Libraryless. Click here for Pure Java version (8492L/48K).
1 | sclass PtSet extends java.util.AbstractSet<Pt> { |
2 | final CompactLongSet set; |
3 | |
4 | *() { set = new CompactLongSet; } |
5 | *(int size) { set = new CompactLongSet(size); } |
6 | |
7 | *(Iterable<Pt> l) { |
8 | this(); |
9 | if (l != null) for (Pt p : l) add(p); |
10 | } |
11 | |
12 | *(Cl<Pt> l) { |
13 | this(l(l)); |
14 | if (l != null) for (Pt p : l) add(p); |
15 | } |
16 | |
17 | public int size() { ret set.size(); } |
18 | |
19 | @Override |
20 | public bool contains(O o) { |
21 | ret contains(o/Pt); |
22 | } |
23 | |
24 | public bool contains(Pt p) { |
25 | ret set.contains(ptToLong(p)); |
26 | } |
27 | |
28 | public bool contains(int x, int y) { |
29 | ret set.contains(ptToLong(x, y)); |
30 | } |
31 | |
32 | public bool add(Pt p) { |
33 | ret set.add(ptToLong(p)); |
34 | } |
35 | |
36 | public bool add(int x, int y) { |
37 | ret set.add(ptToLong(x, y)); |
38 | } |
39 | |
40 | public bool remove(Pt p) { |
41 | ret set.remove(ptToLong(p)); |
42 | } |
43 | |
44 | public bool remove(int x, int y) { |
45 | ret set.remove(ptToLong(x, y)); |
46 | } |
47 | |
48 | public void clear { set.clear(); } |
49 | |
50 | public Iterator<Pt> iterator() { |
51 | RenamedLongIterator it = set.iterator(); |
52 | ret new ItIt<Pt> { |
53 | public bool hasNext() { |
54 | ret it.hasNext(); |
55 | } |
56 | |
57 | public Pt next() { |
58 | ret ptFromLong(it.nextLong()); |
59 | } |
60 | |
61 | public void remove() { |
62 | it.remove(); |
63 | } |
64 | }; |
65 | } |
66 | } |
Began life as a copy of #1033756
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035008 |
Snippet name: | PtSet - hash set of points (Pt) based on CompactLongSet [dev.] |
Eternal ID of this version: | #1035008/8 |
Text MD5: | 8a82dff65fdaca45620539e139051300 |
Transpilation MD5: | 624298d70400db2bacdceb12239d7177 |
Author: | stefan |
Category: | javax / collections |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-05-13 15:02:47 |
Source code size: | 1320 bytes / 66 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 230 / 313 |
Version history: | 7 change(s) |
Referenced in: | [show references] |