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

41
LINES

< > BotCompany Repo | #1017203 // antiFilter - drop where predicate matches

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

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

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

  new L x;
  if (c != null) for (O o : c)
    if (!isTrue(callF(pred, o)))
      x.add(o);
  ret x;
}

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

static L antiFilter(O pred, O[] c) {
  ret antiFilter(pred, wrapArrayAsList(c));
}

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

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

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

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

Author comment

Began life as a copy of #1003524

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, elmgxqgtpvxh, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1017203
Snippet name: antiFilter - drop where predicate matches
Eternal ID of this version: #1017203/7
Text MD5: 3831f40f089d9226e65ce5a87ec20a77
Transpilation MD5: f3c15e990a5e461107db8006973c32dd
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-06-13 14:02:34
Source code size: 1007 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 421 / 529
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1017294 - filterAntiFilter - make "true" and "false" list using predicate
#1035249 - antiFilterToSet - drop where predicate matches