Libraryless. Click here for Pure Java version (116L/1K).
1 | static <A> CloseableIterableIterator<A> closeableIterableIterator(Iterator<A> it) { |
2 | if (it cast CloseableIterableIterator) ret it; |
3 | ret it == null ? null : new CloseableIterableIterator<A> { |
4 | public bool hasNext() { ret it.hasNext(); } |
5 | public A next() { ret it.next(); } |
6 | public void remove() { it.remove(); } |
7 | close { closeOpt(it); } |
8 | }; |
9 | } |
10 | |
11 | static <A> CloseableIterableIterator<A> closeableIterableIterator(Cl<A> it) { |
12 | ret closeableIterableIterator(iterator(it)); |
13 | } |
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: | 156 / 208 |
Version history: | 2 change(s) |
Referenced in: | [show references] |