Libraryless. Click here for Pure Java version (3910L/22K).
1 | sclass HasKeyMap<A, B extends HasKey<A>> /*extends AbstractMap<A, B>*/ implements Iterable<B> { |
2 | new Map<A, B> map; |
3 | |
4 | *() {} |
5 | //*(Map<A, B> map) { putAll(this.map, map); } |
6 | *(Iterable<B> l) { addAll(l); } |
7 | |
8 | void addAll(Iterable<B> l) { |
9 | fOr (b : l) if (b != null) map.put(b.key(), b); |
10 | } |
11 | |
12 | public Iterator<B> iterator() { ret valueIterator(map); } |
13 | |
14 | A firstKey() { ret main firstKey(map); } |
15 | |
16 | public int size() { ret map.size(); } |
17 | |
18 | Set<A> keys aka keySet() { ret map.keySet(); } |
19 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1032972 |
Snippet name: | HasKeyMap - a combination of set + map for elements implementing HasKey |
Eternal ID of this version: | #1032972/13 |
Text MD5: | 4bca81cb3b4741fa7d418a493f85dc10 |
Transpilation MD5: | 107246c97a98e2ac67aefef15301051f |
Author: | stefan |
Category: | javax / stefan's os |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-18 04:18:04 |
Source code size: | 524 bytes / 19 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 187 / 321 |
Version history: | 12 change(s) |
Referenced in: | [show references] |