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

19
LINES

< > BotCompany Repo | #1013683 // countOccurrencesIC (ignore case)

JavaX fragment (include)

// element occurrences in list
static int countOccurrencesIC(Collection<S> c, S x) {
  int n = 0;
  if (c != null) for (S o : c)
    if (eqic(x, o))
      ++n;
  ret n;
}

// string occurrences in string (not counting overlapping)
static int countOccurrencesIC(S s, S x) {
  int i = 0, nx = l(x), count = 0;
  if (nx == 0) ret 0;
  while ((i = indexOfIC(s, x, i)) >= 0) {
    ++count;
    i += nx;
  }
  ret count;
}

Author comment

Began life as a copy of #1008879

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: #1013683
Snippet name: countOccurrencesIC (ignore case)
Eternal ID of this version: #1013683/4
Text MD5: b200e991a3e3e39d06de76d58becb88d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-12 20:31:26
Source code size: 434 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 402 / 450
Version history: 3 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)