Libraryless. Click here for Pure Java version (2780L/16K).
static <A> Chain<A> toChain(Iterable<A> l) { Iterator<A> it = iterator(l); if (!it.hasNext()) null; Chain<A> c = new(it.next()); Chain<A> last = c; int size = 1; while (it.hasNext()) { ++size; Chain x = new(it.next()); last.next = x; last = x; } // update sizes and return Chain<A> x = c; while (x != null) { x.size = size--; x = x.next; } ret c; }
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1030890 | 
| Snippet name: | toChain | 
| Eternal ID of this version: | #1030890/2 | 
| Text MD5: | 073289eec4dcdc2bfd022f86d8e1728d | 
| Transpilation MD5: | 7cfd9b7fdbc6976b606a4178592b6af4 | 
| Author: | stefan | 
| Category: | javax | 
| Type: | JavaX fragment (include) | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2021-04-06 13:14:11 | 
| Source code size: | 423 bytes / 22 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 374 / 486 | 
| Version history: | 1 change(s) | 
| Referenced in: | [show references] |