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

23
LINES

< > BotCompany Repo | #1030669 // ImmutableListWalker

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

Libraryless. Click here for Pure Java version (2738L/16K).

// the walker is immutable, meaning the only way to
// advance the pointer is to make a new walker object
static persistable class ImmutableListWalker<A> {
  L<A> list;
  int index;
  
  *(L<A> *list) {}
  *(L<A> *list, int *index) {}
  
  bool has() { ret index >= 0 && index < l(list); }
  
  A get() {
    ret _get(list, index);
  }
  
  ImmutableListWalker<A> next() {
    ret new ImmutableListWalker(list, index+1);
  }
  
  bool atEnd() {
    ret index >= l(list);
  }
}

Author comment

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: 260 / 470
Version history: 4 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)