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

27
LINES

< > BotCompany Repo | #1003162 // cloneArray

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

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

1  
static int[] cloneArray(int[] a) {
2  
  if (a == null) null;
3  
  int[] b = new int[a.length];
4  
  System.arraycopy(a, 0, b, 0, a.length);
5  
  ret b;
6  
}
7  
8  
static bool[] cloneArray(bool[] a) {
9  
  if (a == null) null;
10  
  bool[] b = new bool[a.length];
11  
  System.arraycopy(a, 0, b, 0, a.length);
12  
  ret b;
13  
}
14  
15  
static short[] cloneArray(short[] a) {
16  
  if (a == null) null;
17  
  short[] b = new short[a.length];
18  
  System.arraycopy(a, 0, b, 0, a.length);
19  
  ret b;
20  
}
21  
22  
static <A> A[] cloneArray(A[] a) {
23  
  if (a == null) null;
24  
  A[] b = arrayOfSameType(a, a.length);
25  
  System.arraycopy(a, 0, b, 0, a.length);
26  
  ret b;
27  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1003162
Snippet name: cloneArray
Eternal ID of this version: #1003162/4
Text MD5: d6d3dd925c6817149d8fd055375607b6
Transpilation MD5: b4ae2bb05f70f7e7e702625211a93345
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-02 04:39:19
Source code size: 617 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 595 / 646
Version history: 3 change(s)
Referenced in: [show references]