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

32
LINES

< > BotCompany Repo | #1012671 // iteratorFromFunction_withEndMarker_f0

JavaX fragment (include)

please include function iteratorFromFunction_withEndMarker.

static <A> IterableIterator<A> iteratorFromFunction_withEndMarker_f0(final F0<A> f) {
  class IFF2 extends IterableIterator<A> {
    A a;
    bool have, done;
    
    public bool hasNext() {
      getNext();
      ret !done;
    }
    
    public A next() {
      getNext();
      if (done) fail();
      A _a = a;
      a = null;
      have = false;
      ret _a;
    }
    
    void getNext() {
      if (done || have) ret;
      O o = f.get();
      if (o == iteratorFromFunction_endMarker)
        ret with done = true;
      a = (A) o;
      set have;
    }
  };
  ret new IFF2;
}

Author comment

Began life as a copy of #1012440

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1012671
Snippet name: iteratorFromFunction_withEndMarker_f0
Eternal ID of this version: #1012671/4
Text MD5: fa920f5471d3cc4b63e6b7991a81df65
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-28 11:47:25
Source code size: 678 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 533 / 1313
Version history: 3 change(s)
Referenced in: [show references]