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

44
LINES

< > BotCompany Repo | #1015351 // filterIterator

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

Libraryless. Click here for Pure Java version (2310L/14K).

static <A> IterableIterator<A> filterIterator(final Iterator<A> it, final F1<A, Bool> f) {
  if (it == null) null;
  ret iff(func -> O {
    while (it.hasNext()) {
      A a = it.next();
      if (callF(f, a))
        ret a;
    }
    ret endMarker();
  });
}

static <A> IterableIterator<A> filterIterator(final Iterator<A> it, final IF1<A, Bool> f) {
  if (it == null) null;
  ret iff(func -> O {
    while (it.hasNext()) {
      A a = it.next();
      if (callF(f, a))
        ret a;
    }
    ret endMarker();
  });
}

static <A> IterableIterator<A> filterIterator(final F1<A, Bool> f, final Iterator<A> it) {
  ret filterIterator(it, f);
}

static <A> IterableIterator<A> filterIterator(Cl<A> l, IF1<A, Bool> f) {
  if (l == null) null;
  Iterator<A> it = iterator(l);
  ret iff(func -> O {
    while (it.hasNext()) {
      A a = it.next();
      if (f.get(a))
        ret a;
    }
    ret endMarker();
  });
}

static <A> ItIt<A> lambdaMapLike filterIterator(IF1<A, Bool> f, Iterator<A> it) {
  ret filterIterator(it, f);
}

Author comment

Began life as a copy of #1014420

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1015351
Snippet name: filterIterator
Eternal ID of this version: #1015351/9
Text MD5: d1740ae292707c9c0ca4cde746d46fe0
Transpilation MD5: a6331d2d8092587fad91ff5f2c655b80
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-16 18:57:09
Source code size: 1072 bytes / 44 lines
Pitched / IR pitched: No / No
Views / Downloads: 339 / 446
Version history: 8 change(s)
Referenced in: [show references]