Libraryless. Click here for Pure Java version (2024L/13K).
1 | static <A> ItIt<A> roundRobinCombinedIterator(Iterator<A>... iterators) { |
2 | ret roundRobinCombinedIterator(wrapAsList(iterators)); |
3 | } |
4 | |
5 | static <A> ItIt<A> roundRobinCombinedIterator(Cl<? extends Iterator<A>> iterators) { |
6 | if (empty(iterators)) ret emptyItIt(); |
7 | class Robin implements IF0 { |
8 | L<? extends Iterator<A>> activeIterators = cloneList(iterators); |
9 | int i; |
10 | |
11 | public O get() { |
12 | while licensed { |
13 | Iterator<A> it = activeIterators.get(i); |
14 | if (!it.hasNext()) { |
15 | activeIterators.remove(i); |
16 | if (empty(activeIterators)) break; |
17 | i %= l(activeIterators); |
18 | } else { |
19 | i = (i+1) % l(activeIterators); |
20 | ret it.next(); |
21 | } |
22 | } |
23 | ret endMarker(); |
24 | } |
25 | } |
26 | |
27 | ret iff(new Robin); |
28 | } |
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: | #1024857 |
Snippet name: | roundRobinCombinedIterator |
Eternal ID of this version: | #1024857/9 |
Text MD5: | ffa0cc33493e610b7e5ee3b5d19064cb |
Transpilation MD5: | 798f80a9b0c7c0d1bc23b24fa64a5202 |
Author: | stefan |
Category: | javax / chess ocr |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-08-29 13:08:21 |
Source code size: | 804 bytes / 28 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 259 / 382 |
Version history: | 8 change(s) |
Referenced in: | [show references] |