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   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, 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: 240 / 255
Version history: 3 change(s)
Referenced in: [show references]

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