1 | static <A> A firstInstanceOf(Iterable i, Class<A> c) { |
2 | if (i == null) null; |
3 | c = primitiveToBoxedTypeOpt(c); |
4 | for (O o : i) |
5 | if (isInstance(c, o)) |
6 | ret (A) o; |
7 | null; |
8 | } |
9 | |
10 | static <A> A firstInstanceOf(Class<A> c, Iterable i) { |
11 | ret firstInstanceOf(i, c); |
12 | } |
13 | |
14 | static <A> A firstInstanceOf(O[] a, Class<A> c) { |
15 | if (a == null) null; |
16 | c = primitiveToBoxedTypeOpt(c); |
17 | for (O o : a) |
18 | if (isInstance(c, o)) |
19 | ret (A) o; |
20 | null; |
21 | } |
Began life as a copy of #1004443
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017030 |
Snippet name: | firstInstanceOf - get first instance of a class from a collection |
Eternal ID of this version: | #1017030/3 |
Text MD5: | 18c029cc63928c47b7b280e89852245d |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-11-30 22:58:17 |
Source code size: | 464 bytes / 21 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 411 / 456 |
Version history: | 2 change(s) |
Referenced in: | [show references] |