static <A> int countSubList(L<A> x, L<A> y) { int n = 0, lx = l(x), ly = l(y); outer: for (int i = 0; i+ly <= lx; i++) { for (int j = 0; j < ly; j++) if (neq(x.get(i+j), y.get(j))) continue outer; ++n; i += ly-1; } ret n; } static <A> int countSubList(L<A> x, A... y) { int n = 0, lx = l(x), ly = l(y); outer: for (int i = 0; i+ly <= lx; i++) { for (int j = 0; j < ly; j++) if (neq(x.get(i+j), y[j])) continue outer; ++n; i += ly-1; } ret n; }
Began life as a copy of #1002135
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: | #1013680 |
| Snippet name: | countSubList - count occurrences of sublist; doesn't count overlapping instances |
| Eternal ID of this version: | #1013680/3 |
| Text MD5: | 40601b5de56fe1d2a6aae451208e098b |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-01-21 14:41:16 |
| Source code size: | 534 bytes / 23 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 653 / 689 |
| Version history: | 2 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |