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

29
LINES

< > BotCompany Repo | #1000657 // indexOfIgnoreCase

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

Libraryless. Click here for Pure Java version (130L/1K).

// works on lists and strings and null

static int indexOfIgnoreCase(L<S> a, S b) {
  ret indexOfIgnoreCase(a, b, 0);
}

static int indexOfIgnoreCase(L<S> a, S b, int i) {
  int n = a == null ? 0 : a.size();
  for (; i < n; i++)
    if (eqic(a.get(i), b)) ret i;
  ret -1;
}

static int indexOfIgnoreCase(S[] a, S b, int i default 0) {
  int n = a == null ? 0 : a.length;
  for (; i < n; i++)
    if (eqic(a[i], b)) ret i;
  ret -1;
}

static int indexOfIgnoreCase(S a, S b) {
  ret indexOfIgnoreCase_manual(a, b);
  /*Matcher m = Pattern.compile(b, Pattern.CASE_INSENSITIVE + Pattern.LITERAL).matcher(a);
  if (m.find()) return m.start(); else ret -1;*/
}

static int indexOfIgnoreCase(S a, S b, int i) {
  ret indexOfIgnoreCase_manual(a, b, i);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lnbujpyubztb, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv

No comments. add comment

Snippet ID: #1000657
Snippet name: indexOfIgnoreCase
Eternal ID of this version: #1000657/14
Text MD5: 320c7c489a7f7a85e0ce6656719cf594
Transpilation MD5: 480dc970f01a25fbc3d923bfc178d95b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-11-02 03:25:51
Source code size: 776 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 854 / 3567
Version history: 13 change(s)
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1011046 - indexOfIC - synonym of indexOfIgnoreCase
#1013296 - indexOfIgnoreCase_manual - probably faster than using regular expressions
#1013297 - indexOfIgnoreCase_usingRegexp
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)