1 | static <A> A collectionEntryAtIndex(Collection<A> l, int i) { |
2 | if (l cast L) ret (A) get(l, i); |
3 | if (i < 0 || i >= l(l)) null; |
4 | Iterator<A> it = iterator(l); |
5 | while (i-- > 0) if (!it.hasNext()) null; else it.next(); |
6 | ret it.hasNext() ? it.next() : null; |
7 | } |
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1021046 |
Snippet name: | collectionEntryAtIndex - scans if necessary |
Eternal ID of this version: | #1021046/2 |
Text MD5: | 7f0d20682889e2511e446850094aed36 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-01-19 18:00:09 |
Source code size: | 266 bytes / 7 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 251 / 288 |
Version history: | 1 change(s) |
Referenced in: | [show references] |