Libraryless. Click here for Pure Java version (2738L/16K).
1 | // the walker is immutable, meaning the only way to |
2 | // advance the pointer is to make a new walker object |
3 | static persistable class ImmutableListWalker<A> { |
4 | L<A> list; |
5 | int index; |
6 | |
7 | *(L<A> *list) {} |
8 | *(L<A> *list, int *index) {} |
9 | |
10 | bool has() { ret index >= 0 && index < l(list); } |
11 | |
12 | A get() { |
13 | ret _get(list, index); |
14 | } |
15 | |
16 | ImmutableListWalker<A> next() { |
17 | ret new ImmutableListWalker(list, index+1); |
18 | } |
19 | |
20 | bool atEnd() { |
21 | ret index >= l(list); |
22 | } |
23 | } |
Began life as a copy of #1030668
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030669 |
Snippet name: | ImmutableListWalker |
Eternal ID of this version: | #1030669/5 |
Text MD5: | 8fa98dff46cbc5bd2ab7a2ff7d06ebd5 |
Transpilation MD5: | 5824510264452a13f28e2b8aaa8d15e0 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-02-26 11:27:23 |
Source code size: | 498 bytes / 23 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 261 / 472 |
Version history: | 4 change(s) |
Referenced in: | [show references] |