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


< > BotCompany Repo | #1025514 // indicesOf

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

Libraryless. Click here for Pure Java version (2541L/16K).

static <A> L<Int> indicesOf(L<A> l, A a) {
  if (l == null) null;
  ifclass IContentsIndexedList
  if (l cast IContentsIndexedList)
    ret intArrayToList(l.indicesOf(a));
  ifclass IContentsIndexedList2
  if (l cast IContentsIndexedList2)
    ret map(h -> h/HasIndex.idx, l.indicesOf_treeSetOfHasIndex(a));
  new L<Int> x;
  for (int i = 0; i < l(l); i++)
    if (eq(l.get(i), a))
  ret x;

static <A> L<Int> indicesOf(S s, S x) {
  int i = -1;
  new L<Int> out;
  while ((i = indexOf(s, x, i+1)) >= 0)
  ret out;

Author comment

Began life as a copy of #1004477

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1025514
Snippet name: indicesOf
Eternal ID of this version: #1025514/9
Text MD5: e6526d2d54e8018372fe48c1f0240230
Transpilation MD5: 734553d978168300f9aa15c9ee761dbf
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-11 12:52:06
Source code size: 597 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 169 / 276
Version history: 8 change(s)
Referenced in: [show references]