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

26
LINES

< > BotCompany Repo | #1024889 // iteratorFromFunction_if0 - ends on null

JavaX fragment (include)

1  
static <A> IterableIterator<A> iteratorFromFunction_if0(final IF0<A> f) {
2  
  class IFF2 extends IterableIterator<A> {
3  
    A a;
4  
    bool done;
5  
    
6  
    public bool hasNext() {
7  
      getNext();
8  
      ret !done;
9  
    }
10  
    
11  
    public A next() {
12  
      getNext();
13  
      if (done) fail();
14  
      A _a = a;
15  
      a = null;
16  
      ret _a;
17  
    }
18  
    
19  
    void getNext() {
20  
      if (done || a != null) ret;
21  
      a = f.get();
22  
      done = a == null;
23  
    }
24  
  };
25  
  ret new IFF2;
26  
}

Author comment

Began life as a copy of #1012440

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024889
Snippet name: iteratorFromFunction_if0 - ends on null
Eternal ID of this version: #1024889/1
Text MD5: b27ffd95209b36b4c9f41d951a901045
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-28 19:41:07
Source code size: 490 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 222 / 260
Referenced in: [show references]