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

18
LINES

< > BotCompany Repo | #1014874 // subByteArray

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

Libraryless. Click here for Pure Java version (3809L/22K).

1  
static byte[] subByteArray(byte[] b, int start) {
2  
  ret subByteArray(b, start, l(b));
3  
}
4  
  
5  
static byte[] subByteArray(byte[] 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 byte[0];
9  
  byte[] x = new byte[end-start];
10  
  System.arraycopy(b, start, x, 0, end-start);
11  
  ret x;
12  
}
13  
14  
ifclass IntRange
15  
static byte[] subByteArray(byte[] b, IntRange r) {
16  
  ret r == null ?: subByteArray(b, r.start, r.end);
17  
}
18  
endif

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1014874
Snippet name: subByteArray
Eternal ID of this version: #1014874/5
Text MD5: 3bdc625d1722eb26bfb7c1c89ae8640b
Transpilation MD5: 08c70273fb665aaaa651c2ad6ad91745
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-10 22:32:22
Source code size: 511 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 519 / 606
Version history: 4 change(s)
Referenced in: [show references]