1 | static <A> A collectionGet(Collection<A> c, int idx) {
|
2 | if (c == null || idx < 0 || idx >= l(c)) null; |
3 | if (c instanceof L) ret listGet((L<A>) c, idx); |
4 | Iterator<A> it = c.iterator(); |
5 | for (int i = 0; i < idx; i++) if (it.hasNext()) it.next(); else null; |
6 | ret it.hasNext() ? it.next() : null; |
7 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1010783 |
| Snippet name: | collectionGet - get element at index from collection |
| Eternal ID of this version: | #1010783/5 |
| Text MD5: | bd5d08e93d6cab252370dd457657dbee |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-12-03 13:55:09 |
| Source code size: | 305 bytes / 7 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 836 / 910 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |