Libraryless. Click here for Pure Java version (2762L/16K).
1 | static <A> int smartIndexOfSubList(L<A> x, L<A> y) { |
2 | ret smartIndexOfSubList(x, y, 0); |
3 | } |
4 | |
5 | static <A> int smartIndexOfSubList(L<A> x, L<A> y, int i) { |
6 | outer: for (; i+l(y) <= l(x); i++) { |
7 | for (int j = 0; j < l(y); j++) |
8 | if (neq(x.get(i+j), y.get(j))) |
9 | continue outer; |
10 | break; |
11 | } |
12 | ret i; |
13 | } |
14 | |
15 | static <A> int smartIndexOfSubList(L<A> x, A[] y, int i) { |
16 | outer: for (; i+l(y) <= l(x); i++) { |
17 | for (int j = 0; j < l(y); j++) |
18 | if (neq(x.get(i+j), y[j])) |
19 | continue outer; |
20 | break; |
21 | } |
22 | ret i; |
23 | } |
Began life as a copy of #1002135
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1031335 |
Snippet name: | smartIndexOfSubList |
Eternal ID of this version: | #1031335/1 |
Text MD5: | 45cdbeafef6133cd8d3946e67cf6e20c |
Transpilation MD5: | 415368e2a8e97a7d1dca0f575160dfb3 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-05 09:11:37 |
Source code size: | 551 bytes / 23 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 193 / 268 |
Referenced in: | [show references] |