Libraryless. Click here for Pure Java version (9882L/55K).
1 | sclass Tree<A> extends Var<A> {
|
2 | L<Tree<A>> children; |
3 | |
4 | *() {}
|
5 | *(A *v) {}
|
6 | *(A *v, Iterable<Tree<A>> children) { this.children = cloneList(children); }
|
7 | |
8 | toString { new LS out; toString(out, 0); ret lines(out); }
|
9 | |
10 | // Note: This doesn't call the children() method |
11 | void toString(LS out, int indent) {
|
12 | out.add(spaces(indent) + str(v)); |
13 | for (Tree<A> t : unnull(children)) |
14 | t.toString(out, indent+2); |
15 | } |
16 | |
17 | A value() { ret get(); }
|
18 | |
19 | // if you override, make sure to set field children |
20 | L<Tree<A>> children() { ret children; }
|
21 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1019095 |
| Snippet name: | Tree<A> - simple generic tree class (all-in-one class) |
| Eternal ID of this version: | #1019095/19 |
| Text MD5: | c2d62774860367d1d9a4ab06e1227246 |
| Transpilation MD5: | 165db8ad3d6e3d02748571d93568c082 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-07-01 05:54:20 |
| Source code size: | 579 bytes / 21 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 646 / 1373 |
| Version history: | 18 change(s) |
| Referenced in: | [show references] |