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)

static <A> IterableIterator<A> iteratorFromFunction_if0(final IF0<A> f) {
  class IFF2 extends IterableIterator<A> {
    A a;
    bool done;
    
    public bool hasNext() {
      getNext();
      ret !done;
    }
    
    public A next() {
      getNext();
      if (done) fail();
      A _a = a;
      a = null;
      ret _a;
    }
    
    void getNext() {
      if (done || a != null) ret;
      a = f.get();
      done = a == null;
    }
  };
  ret new IFF2;
}

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: 221 / 259
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)