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

12
LINES

< > BotCompany Repo | #1030689 // byteArrayToList (makes an ArrayList)

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

Libraryless. Click here for Pure Java version (37L/1K).

1  
static <A> ArrayList<Byte> byteArrayToList(byte[] a) {
2  
  if (a == null) null;
3  
  ret byteArrayToList(a, 0, a.length);
4  
}
5  
6  
// no range checking on from/to in the interest of speed
7  
static <A> ArrayList<Byte> byteArrayToList(byte[] a, int from, int to) {
8  
  if (a == null) null;
9  
  ArrayList<Byte> l = new(to-from);
10  
  for (int i = from; i < to; i++) l.add(a[i]);
11  
  ret l;
12  
}

Author comment

Began life as a copy of #1025516

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030689
Snippet name: byteArrayToList (makes an ArrayList)
Eternal ID of this version: #1030689/1
Text MD5: 78cffb4e75aec592b6e671442cd22789
Transpilation MD5: 65cf753b2825ea99509d9f91a8834b94
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-03-07 18:37:27
Source code size: 377 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 208 / 303
Referenced in: [show references]