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

13
LINES

< > BotCompany Repo | #1036525 // closeableIterableIterator - convert Iterator or Collection to CloseableIterableIterator

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (116L/1K).

static <A> CloseableIterableIterator<A> closeableIterableIterator(Iterator<A> it) {
  if (it cast CloseableIterableIterator) ret it;
  ret it == null ? null : new CloseableIterableIterator<A> {
    public bool hasNext() { ret it.hasNext(); }
    public A next() { ret it.next(); }
    public void remove() { it.remove(); }
    close { closeOpt(it); }
  };
}

static <A> CloseableIterableIterator<A> closeableIterableIterator(Cl<A> it) {
  ret closeableIterableIterator(iterator(it));
}

Author comment

Began life as a copy of #1014178

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1036525
Snippet name: closeableIterableIterator - convert Iterator or Collection to CloseableIterableIterator
Eternal ID of this version: #1036525/3
Text MD5: 8487ef68144f7df0ef354361c4b85b9a
Transpilation MD5: 1a5730cd8807ada540d2bab0ceacc199
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-01-22 16:50:03
Source code size: 497 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 157 / 208
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)