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

15
LINES

< > BotCompany Repo | #1033229 // virtualCountList

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

Libraryless. Click here for Pure Java version (7890L/44K).

1  
static L<Int> virtualCountList(int n) {
2  
  ret new RandomAccessAbstractList<Int>() {
3  
    public int size() { ret n; }
4  
    public Int get(int i) { ret i; }
5  
  };
6  
}
7  
8  
// to is exclusive
9  
static L<Int> virtualCountList(int from, int to) {
10  
  int n = max(to-from, 0);
11  
  ret new RandomAccessAbstractList<Int>() {
12  
    public int size() { ret n; }
13  
    public Int get(int i) { ret from+i; }
14  
  };
15  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033229
Snippet name: virtualCountList
Eternal ID of this version: #1033229/4
Text MD5: 4ecbe2a1c4840dee2dba59fd7549d4ff
Transpilation MD5: afc5b96cd3350f5e5726a5adc06a4da1
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-17 17:33:31
Source code size: 398 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 105 / 170
Version history: 3 change(s)
Referenced in: [show references]