Libraryless. Click here for Pure Java version (2682L/17K).
1 | // order of returned elements is undefined, but root is returned first |
2 | // doesn't uniquify output, so make sure you don't produce a loop |
3 | static <A> ItIt<A> recursiveIterator(A root, IF1<A, Iterable<A>> getChildren) { |
4 | LinkedList<A> list = llLinkedList(root); |
5 | ret iff(func { |
6 | if (empty(list)) |
7 | ret endMarker(); |
8 | A a = popFirst(list); |
9 | addAll(list, getChildren.get(a)); |
10 | ret a; |
11 | }); |
12 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1029281 |
Snippet name: | recursiveIterator |
Eternal ID of this version: | #1029281/2 |
Text MD5: | 3edc9ec1a8ae59790133b3a5b74ad5ec |
Transpilation MD5: | 69c241520639054949c619a8fc382486 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-07-29 20:43:27 |
Source code size: | 415 bytes / 12 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 188 / 267 |
Version history: | 1 change(s) |
Referenced in: | [show references] |