Libraryless. Click here for Pure Java version (2290L/15K).
1 | static <A> ItIt<A> mapLike transitiveHullIteratorOfFunction(IF1<A, Cl<A>> f, Set<A> initial, O... _) { |
2 | Set<A> seen = similarEmptySet(initial); |
3 | |
4 | // Make pool of iterators |
5 | final new LinkedList<Iterator<A>> pool; |
6 | pool.add(iterator(initial)); |
7 | ret iteratorFromFunction(new F0<A> { |
8 | int n = 0; |
9 | |
10 | public A get() { |
11 | while ping (!empty(pool)) { |
12 | Iterator<A> it = first(pool); |
13 | if (!it.hasNext()) continue with removeFirst(pool); |
14 | |
15 | // Get entry and check if seen already |
16 | A entry = it.next(); |
17 | if (!seen.add(entry)) continue; |
18 | |
19 | // found new entry - return and schedule for further analysis |
20 | Collection<A> newStuff = cast callF(f, entry); |
21 | if (nempty(newStuff)) |
22 | pool.add(iterator(newStuff)); |
23 | ++n; |
24 | ret entry; |
25 | } |
26 | null; |
27 | } |
28 | }); |
29 | } |
Began life as a copy of #1023767
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: | #1026495 |
Snippet name: | transitiveHullIteratorOfFunction |
Eternal ID of this version: | #1026495/5 |
Text MD5: | 276efbfd46dee58cc92a3c6450b0adf5 |
Transpilation MD5: | 9c15747f0525f6b36b171e7c067fea31 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-01-06 23:53:05 |
Source code size: | 875 bytes / 29 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 191 / 285 |
Version history: | 4 change(s) |
Referenced in: | [show references] |