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

42
LINES

< > BotCompany Repo | #1003524 - filter

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

Libraryless. Click here for Pure Java version (1780L/12K).

static <A> L<A> filter(Iterable<A> c, O pred) {
  if (pred instanceof F1) ret filter(c, (F1<A, Bool>) pred);

  ifdef filter_debug
    print("Slow filter called");
  endifdef
  new L x;
  if (c != null) for (O o : c)
    if (isTrue(callF(pred, o)))
      x.add(o);
  ret x;
}

static L filter(O pred, Iterable c) {
  ret filter(c, pred);
}

static <A, B extends A> L<B> filter(Iterable<B> c, F1<A, Bool> pred) {
  new L x;
  if (c != null) for (B o : c)
    if (pred.get(o))
      x.add(o);
  ret x;
}

static <A, B extends A> L<B> filter(F1<A, Bool> pred, Iterable<B> c) {
  ret filter(c, pred);
}

//ifclass IF1
static <A, B extends A> L<B> filter(Iterable<B> c, IF1<A, Bool> pred) {
  new L x;
  if (c != null) for (B o : c)
    if (pred.get(o))
      x.add(o);
  ret x;
}

static <A, B extends A> L<B> filter(IF1<A, Bool> pred, Iterable<B> c) {
  ret filter(c, pred);
}
//endif

download  show line numbers  debug dex   

Travelled to 11 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tslmcundralx, tvejysmllsmz, whxojlpjdney

No comments. add comment

Snippet ID: #1003524
Snippet name: filter
Eternal ID of this version: #1003524/12
Text MD5: c4fc77267f9c389217dd867dffcbf0e9
Transpilation MD5: 5a50f4a82a8a75c748e5422db8237066
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-13 17:07:36
Source code size: 922 bytes / 42 lines
Pitched / IR pitched: No / No
Views / Downloads: 352 / 431
Version history: 11 change(s)
Referenced in: [show references]