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

18
LINES

< > BotCompany Repo | #1024596 // subIntArray

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

Transpiled version (2634L) is out of date.

1  
static int[] subIntArray(int[] b, int start) {
2  
  ret subIntArray(b, start, l(b));
3  
}
4  
  
5  
static int[] subIntArray(int[] b, int start, int end) {
6  
  start = max(start, 0); end = min(end, l(b));
7  
  if (start == 0 && end == l(b)) ret b;
8  
  if (start >= end) ret new int[0];
9  
  int[] x = new int[end-start];
10  
  System.arraycopy(b, start, x, 0, end-start);
11  
  ret x;
12  
}
13  
14  
ifclass IntRange
15  
static int[] subIntArray(int[] a, IntRange r) {
16  
  ret r == null ? null : subIntArray(a, r.start, r.end);
17  
}
18  
endif

Author comment

Began life as a copy of #1014874

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: #1024596
Snippet name: subIntArray
Eternal ID of this version: #1024596/3
Text MD5: f44dcb6fbf74f75e2eac3f5954b11055
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-11-12 10:37:48
Source code size: 503 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 219 / 340
Version history: 2 change(s)
Referenced in: [show references]