1 | // element occurrences in list |
2 | static int countOccurrencesIC(Collection<S> c, S x) { |
3 | int n = 0; |
4 | if (c != null) for (S o : c) |
5 | if (eqic(x, o)) |
6 | ++n; |
7 | ret n; |
8 | } |
9 | |
10 | // string occurrences in string (not counting overlapping) |
11 | static int countOccurrencesIC(S s, S x) { |
12 | int i = 0, nx = l(x), count = 0; |
13 | if (nx == 0) ret 0; |
14 | while ((i = indexOfIC(s, x, i)) >= 0) { |
15 | ++count; |
16 | i += nx; |
17 | } |
18 | ret count; |
19 | } |
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: | 401 / 449 |
Version history: | 3 change(s) |
Referenced in: | [show references] |