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

11
LINES

< > BotCompany Repo | #1026975 // cloneSubByteArray - always make a copy

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

Libraryless. Click here for Pure Java version (2151L/14K).

1  
static byte[] cloneSubByteArray(byte[] b, int start) {
2  
  ret cloneSubByteArray(b, start, l(b));
3  
}
4  
  
5  
static byte[] cloneSubByteArray(byte[] b, int start, int end) {
6  
  start = max(start, 0); end = min(end, l(b));
7  
  if (start >= end) ret new byte[0];
8  
  byte[] x = new byte[end-start];
9  
  System.arraycopy(b, start, x, 0, end-start);
10  
  ret x;
11  
}

Author comment

Began life as a copy of #1014874

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1026975
Snippet name: cloneSubByteArray - always make a copy
Eternal ID of this version: #1026975/1
Text MD5: 77014c6ded1a9ae20b242db8c9241c17
Transpilation MD5: d54ff20f5ff98b31e2c20268ea7a6dc8
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-05 02:11:08
Source code size: 350 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 287 / 369
Referenced in: [show references]