Libraryless. Click here for Pure Java version (3910L/22K).
sclass HasKeyMap<A, B extends HasKey<A>> /*extends AbstractMap<A, B>*/ implements Iterable<B> { new Map<A, B> map; *() {} //*(Map<A, B> map) { putAll(this.map, map); } *(Iterable<B> l) { addAll(l); } void addAll(Iterable<B> l) { fOr (b : l) if (b != null) map.put(b.key(), b); } public Iterator<B> iterator() { ret valueIterator(map); } A firstKey() { ret main firstKey(map); } public int size() { ret map.size(); } Set<A> keys aka keySet() { ret map.keySet(); } }
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: | 438 / 612 |
| Version history: | 12 change(s) |
| Referenced in: | #1033027 - TreeHasKeyMap - sorted HasKeyMap #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |