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)

1  
please include function iteratorFromFunction_withEndMarker.
2  
3  
static <A> IterableIterator<A> iteratorFromFunction_withEndMarker_f0(final F0<A> f) {
4  
  class IFF2 extends IterableIterator<A> {
5  
    A a;
6  
    bool have, done;
7  
    
8  
    public bool hasNext() {
9  
      getNext();
10  
      ret !done;
11  
    }
12  
    
13  
    public A next() {
14  
      getNext();
15  
      if (done) fail();
16  
      A _a = a;
17  
      a = null;
18  
      have = false;
19  
      ret _a;
20  
    }
21  
    
22  
    void getNext() {
23  
      if (done || have) ret;
24  
      O o = f.get();
25  
      if (o == iteratorFromFunction_endMarker)
26  
        ret with done = true;
27  
      a = (A) o;
28  
      set have;
29  
    }
30  
  };
31  
  ret new IFF2;
32  
}

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: 534 / 1314
Version history: 3 change(s)
Referenced in: [show references]