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

25
LINES

< > BotCompany Repo | #1007655 // indexOfAny - index of one of multiple elements

JavaX fragment (include)

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

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

static <A> int indexOfAny(L<A> l, int i, Collection<A> x) {
  if (nempty(x))
    while (i < l(l))
      if (x.contains(l.get(i))) ret i; else ++i;
  ret -1;
}

static int indexOfAny(S s, int i, S chars) {
  for (; i < l(s); i++)
    if (chars.indexOf(s.charAt(i)) >= 0)
      ret i;
  ret -1;
}

static int indexOfAny(S s, S chars) { ret indexOfAny(s, 0, chars); }

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: #1007655
Snippet name: indexOfAny - index of one of multiple elements
Eternal ID of this version: #1007655/10
Text MD5: 2ebf2b8500d5a7b2fd2d853d0197763d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-06-29 18:53:47
Source code size: 601 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 672 / 683
Version history: 9 change(s)
Referenced in: [show references]