Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

23
LINES

< > BotCompany Repo | #1031335 // smartIndexOfSubList

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2762L/16K).

static <A> int smartIndexOfSubList(L<A> x, L<A> y) {
  ret smartIndexOfSubList(x, y, 0);
}

static <A> int smartIndexOfSubList(L<A> x, L<A> y, int i) {
  outer: for (; i+l(y) <= l(x); i++) {
    for (int j = 0; j < l(y); j++)
      if (neq(x.get(i+j), y.get(j)))
        continue outer;
    break;
  }
  ret i;
}

static <A> int smartIndexOfSubList(L<A> x, A[] y, int i) {
  outer: for (; i+l(y) <= l(x); i++) {
    for (int j = 0; j < l(y); j++)
      if (neq(x.get(i+j), y[j]))
        continue outer;
    break;
  }
  ret i;
}

Author comment

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: 77 / 113
Referenced in: [show references]