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

16
LINES

< > BotCompany Repo | #1008434 // smartIndexOfAny - index of one of multiple elements

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

Libraryless. Click here for Pure Java version (2190L/14K).

static <A> int smartIndexOfAny(L<A> l, int i, A... x) {
  while (i < l(l))
    if (eqOneOf(l.get(i), x)) ret i; else ++i;
  ret l(l);
}

static <A> int smartIndexOfAny(L<A> l, A... x) {
  ret smartIndexOfAny(l, 0, x);
}

static <A> int smartIndexOfAny(L<A> l, int i, Cl<A> x) {
  int n = l(l);
  while (i < n)
    if (contains(x, l.get(i))) ret i; else ++i;
  ret n;
}

Author comment

Began life as a copy of #1007655

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1008434
Snippet name: smartIndexOfAny - index of one of multiple elements
Eternal ID of this version: #1008434/3
Text MD5: 1db27d46a6db26cc6bbe349be2930a5a
Transpilation MD5: f0c150604181f9cac716debdcf0c0d86
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-23 11:03:08
Source code size: 385 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 445 / 514
Version history: 2 change(s)
Referenced in: [show references]