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

15
LINES

< > BotCompany Repo | #1034672 // indicesOf_collectionOfHasIndex - faster with IContentsIndexedList2, similar speed as indicesOf for normal list

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

Libraryless. Click here for Pure Java version (5026L/28K).

static <A> Cl<HasIndex> indicesOf_collectionOfHasIndex(L<A> l, A a) {
  if (l == null) null;
  
  ifclass IContentsIndexedList2
  if (l cast IContentsIndexedList2)
    ret l.indicesOf_treeSetOfHasIndex(a);
  endif
  
  new L<HasIndex> x;
  int n = l(l);
  for (int i = 0; i < n; i++)
    if (eq(l.get(i), a))
      x.add(HasIndex(i));
  ret x;
}

Author comment

Began life as a copy of #1025514

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034672
Snippet name: indicesOf_collectionOfHasIndex - faster with IContentsIndexedList2, similar speed as indicesOf for normal list
Eternal ID of this version: #1034672/1
Text MD5: 47d8c39e1618162852a3cdb5c5a1fca2
Transpilation MD5: fde40c2b53cc1de394ed0d9e9b7304d5
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-01 16:43:28
Source code size: 359 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 92 / 124
Referenced in: [show references]