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

49
LINES

< > BotCompany Repo | #1001878 - indexOf - fills various gaps in java.util.List API

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

Libraryless. Click here for Pure Java version (2126L/13K).

static <A> int indexOf(L<A> l, A a, int startIndex) {
  if (l == null) ret -1;
  int n = l(l);
  for (int i = startIndex; i < n; i++)
    if (eq(l.get(i), a))
      ret i;
  ret -1;
}

static <A> int indexOf(L<A> l, int startIndex, A a) {
  ret indexOf(l, a, startIndex);
}

static <A> int indexOf(L<A> l, A a) {
  if (l == null) ret -1;
  ret l.indexOf(a);
}

static int indexOf(S a, S b) {
  ret a == null || b == null ? -1 : a.indexOf(b);
}

static int indexOf(S a, S b, int i) {
  ret a == null || b == null ? -1 : a.indexOf(b, i);
}

static int indexOf(S a, char b) {
  ret a == null ? -1 : a.indexOf(b);
}

static int indexOf(S a, int i, char b) {
  ret indexOf(a, b, i);
}

static int indexOf(S a, char b, int i) {
  ret a == null ? -1 : a.indexOf(b, i);
}

static int indexOf(S a, int i, S b) {
  ret a == null || b == null ? -1 : a.indexOf(b, i);
}

static <A> int indexOf(A[] x, A a) {
  int n = l(x);
  for (int i = 0; i < n; i++)
    if (eq(x[i], a))
      ret i;
  ret -1;
}

download  show line numbers  debug dex   

Travelled to 11 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1001878
Snippet name: indexOf - fills various gaps in java.util.List API
Eternal ID of this version: #1001878/7
Text MD5: 5e843b87deaaa7aa13503dab50804505
Transpilation MD5: 89de2503a0b5eb8a282895221aba1096
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-05-05 19:12:38
Source code size: 1035 bytes / 49 lines
Pitched / IR pitched: No / No
Views / Downloads: 481 / 2783
Version history: 6 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1001878 & http://1001878.tinybrain.de