Libraryless. Click here for Pure Java version (13701L/78K).
1 | static <MySSI extends AbstractSSI> L<MySSI> takeFirstNSSILines(int maxLines, Iterable<MySSI> l) { |
2 | if (maxLines == Int.MAX_VALUE) ret asList(l); |
3 | int sum = 0; |
4 | new L<MySSI> out; |
5 | fOr (ssi : l) { |
6 | if (sum >= maxLines) break; |
7 | |
8 | int linesToCopy = min(ssi.height(), maxLines-sum); |
9 | if (linesToCopy < ssi.height()) break; |
10 | out.add(ssi); |
11 | //out.add(linesToCopy == ssi.height() ? ssi : ssi.topPart(linesToCopy)); |
12 | sum += ssi.height(); |
13 | } |
14 | ret out; |
15 | } |
Began life as a copy of #1035613
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035616 |
Snippet name: | takeFirstNSSILines |
Eternal ID of this version: | #1035616/8 |
Text MD5: | 9608f7b2ac6079adad90404933299966 |
Transpilation MD5: | 1b9970d5c91641261e80c8f2a7fa7619 |
Author: | stefan |
Category: | javax / gazelle 22 |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-07-19 22:08:16 |
Source code size: | 484 bytes / 15 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 134 / 219 |
Version history: | 7 change(s) |
Referenced in: | [show references] |