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

11
LINES

< > BotCompany Repo | #1027876 // smartIndexOfPred - index of first element in list that matches a predicate

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

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

static <A> int smartIndexOfPred(L<A> l, IPred<A> pred) {
  ret smartIndexOfPred(l, pred, 0);
}

static <A> int smartIndexOfPred(L<A> l, IPred<A> pred, int i) {
  int n = l(l);
  for (; i < n; i++)
    if (pred.get(l.get(i)))
      ret i;
  ret n;
}

Author comment

Began life as a copy of #1006686

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: #1027876
Snippet name: smartIndexOfPred - index of first element in list that matches a predicate
Eternal ID of this version: #1027876/5
Text MD5: 60769eefd6dc1c1f4da2e14766147244
Transpilation MD5: b81efc4b25312522aaa39d3f1651f243
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-16 14:26:40
Source code size: 258 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 236 / 328
Version history: 4 change(s)
Referenced in: [show references]