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

16
LINES

< > BotCompany Repo | #1004805 // xIndexOf - returns l(s) if not found [quasi synonym of smartIndexOf]

JavaX fragment (include)

// returns l(s) if not found
static int xIndexOf(S s, S sub, int i) {
  if (s == null) ret 0;
  i = s.indexOf(sub, min(i, l(s)));
  ret i >= 0 ? i : l(s);
}

static int xIndexOf(S s, S sub) {
  ret xIndexOf(s, sub, 0);
}

static int xIndexOf(S s, char c) {
  if (s == null) ret 0;
  int i = s.indexOf(c);
  ret i >= 0 ? i : l(s);
}

Author comment

Began life as a copy of #1002497

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004805
Snippet name: xIndexOf - returns l(s) if not found [quasi synonym of smartIndexOf]
Eternal ID of this version: #1004805/1
Text MD5: 66d69b8841fc67bf33b3870f8f8c6a9f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-08-31 18:54:02
Source code size: 346 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 635 / 1516
Referenced in: [show references]