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

20
LINES

< > BotCompany Repo | #1028570 // ListAndIndex

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

Libraryless. Click here for Pure Java version (22032L/133K).

1  
srecord ListAndIndex<A>(L<A> list, int idx) {
2  
  bool atEnd() { ret idx >= l(list); }
3  
  
4  
  A get() { ret _get(list, idx); }
5  
  int size() { ret l(list); }
6  
  
7  
  toString {
8  
    ret subList(list, 0, idx) + ", then " + subList(list, idx);
9  
  }
10  
  
11  
  ListAndIndex<A> plus(int ofs) { ret ListAndIndex(list, idx+ofs); }
12  
  ListAndIndex<A> minus(int ofs) { ret ListAndIndex(list, idx-ofs); }
13  
  
14  
  L<A> list() { ret list; }
15  
  int index aka idx() { ret idx; }
16  
  
17  
  ListAndIndex<A> mapIdx(IF1_IntToInt f) {
18  
    ret ListAndIndex<A>(list, f.get(idx));
19  
  }
20  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028570
Snippet name: ListAndIndex
Eternal ID of this version: #1028570/13
Text MD5: 8f2792b66e1f525f981d30a70a08f166
Transpilation MD5: 615e4fe47a89668bd048f8930867d3b6
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-04-05 21:08:56
Source code size: 558 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 253 / 627
Version history: 12 change(s)
Referenced in: [show references]