Libraryless. Click here for Pure Java version (4767L/27K).
1 | sclass Flattener { |
2 | new L out; |
3 | |
4 | *() {} |
5 | *(O... l) { add(l); } |
6 | |
7 | void add(O o) { |
8 | ifdef Flattener_debug |
9 | print("add " + className(o)); |
10 | endifdef |
11 | if (o cast O[]) for (x : o) add(x); |
12 | else if (o cast Iterable) for (x : o) add(x); |
13 | else if (o != null) out.add(o); |
14 | } |
15 | |
16 | void add(O... l) { add((O) l); } |
17 | |
18 | L toList() { ret out; } |
19 | O[] toArray() { ret toObjectArray(out); } |
20 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033843 |
Snippet name: | Flattener |
Eternal ID of this version: | #1033843/8 |
Text MD5: | 41197f4fb8f962f6a4ea5c8ef895a0d6 |
Transpilation MD5: | 67eeca5d766063388cf09119b718aeee |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-01-07 00:22:00 |
Source code size: | 433 bytes / 20 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 151 / 280 |
Version history: | 7 change(s) |
Referenced in: | [show references] |