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

30
LINES

< > BotCompany Repo | #1017244 // iteratorFromFunction_f0_autoCloseable - end on null

JavaX fragment (include)

static <A> CloseableIterableIterator<A> iteratorFromFunction_f0_autoCloseable(final F0<A> f, final AutoCloseable closeable) {
  class IFF2 extends CloseableIterableIterator<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;
    }
    
    public void close() tex {
      if (closeable != null) closeable.close();
    }
  };
  ret new IFF2;
}

Author comment

Began life as a copy of #1012440

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1017244
Snippet name: iteratorFromFunction_f0_autoCloseable - end on null
Eternal ID of this version: #1017244/6
Text MD5: fb0ea970a52db958ca27009573890cb1
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-19 17:48:12
Source code size: 644 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 393 / 438
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1020979 - iteratorFromFunction_withEndMarker_f0_autoCloseable