1 | static <A> A nextToLastThat(L<A> l, O pred) {
|
2 | int found = 0; |
3 | for (int i = l(l)-1; i >= 0; i--) {
|
4 | A a = l.get(i); |
5 | if (checkCondition(pred, a)) |
6 | if (++found >= 2) |
7 | ret a; |
8 | } |
9 | null; |
10 | } |
11 | |
12 | static <A> A mapLike nextToLastThat(O pred, L<A> l) {
|
13 | ret nextToLastThat(l, pred); |
14 | } |
Began life as a copy of #1021565
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1022066 |
| Snippet name: | nextToLastThat - find next to last element in list that matches a predicate |
| Eternal ID of this version: | #1022066/1 |
| Text MD5: | a64fe43272be8cf5a90c226569b623ed |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-03-06 08:39:35 |
| Source code size: | 307 bytes / 14 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 489 / 538 |
| Referenced in: | [show references] |