1 | // returns l(s) if not found |
2 | static int smartIndexOf(S s, S sub, int i) { |
3 | if (s == null) ret 0; |
4 | i = s.indexOf(sub, min(i, l(s))); |
5 | ret i >= 0 ? i : l(s); |
6 | } |
7 | |
8 | static int smartIndexOf(S s, int i, char c) { |
9 | ret smartIndexOf(s, c, i); |
10 | } |
11 | |
12 | static int smartIndexOf(S s, char c, int i) { |
13 | if (s == null) ret 0; |
14 | i = s.indexOf(c, min(i, l(s))); |
15 | ret i >= 0 ? i : l(s); |
16 | } |
17 | |
18 | static int smartIndexOf(S s, S sub) { |
19 | ret smartIndexOf(s, sub, 0); |
20 | } |
21 | |
22 | static int smartIndexOf(S s, char c) { |
23 | ret smartIndexOf(s, c, 0); |
24 | } |
25 | |
26 | static <A> int smartIndexOf(L<A> l, A sub) { |
27 | ret smartIndexOf(l, sub, 0); |
28 | } |
29 | |
30 | static <A> int smartIndexOf(L<A> l, int start, A sub) { |
31 | ret smartIndexOf(l, sub, start); |
32 | } |
33 | |
34 | static <A> int smartIndexOf(L<A> l, A sub, int start) { |
35 | int i = indexOf(l, sub, start); |
36 | ret i < 0 ? l(l) : i; |
37 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1002497 |
Snippet name: | smartIndexOf - returns l(s) if not found |
Eternal ID of this version: | #1002497/4 |
Text MD5: | 792cd53cec4c83e857ffdd61d265564a |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-02-27 01:26:19 |
Source code size: | 839 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 808 / 816 |
Version history: | 3 change(s) |
Referenced in: | [show references] |