Libraryless. Click here for Pure Java version (3832L/22K).
sclass MinimalChain<A> implements Iterable<A> { A element; MinimalChain<A> next; *() {} *(A *element) {} *(A *element, MinimalChain<A> *next) {} toString { ret str(toList()); } ArrayList<A> toList() { new ArrayList<A> l; MinimalChain<A> c = this; while (c != null) { l.add(c.element); c = c.next; } ret l; } void setElement(A a) { element = a; } void setNext(MinimalChain<A> next) { this.next = next; } // TODO: optimize public Iterator<A> iterator() { ret toList().iterator(); } A get() { ret element; } }
Began life as a copy of #1027968
download show line numbers debug dex old transpilations
Travelled to 5 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
Snippet ID: | #1032878 |
Snippet name: | MinimalChain - singly-linked cons list (like Chain) but without the size field |
Eternal ID of this version: | #1032878/7 |
Text MD5: | f20aba4f9c34fc195151af3aa454f80b |
Transpilation MD5: | 42b739a908438f40818dbba996c587a9 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-10 20:42:50 |
Source code size: | 607 bytes / 28 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 189 / 1361 |
Version history: | 6 change(s) |
Referenced in: | [show references] |