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

46
LINES

< > BotCompany Repo | #1031245 // primitiveArrayToBoxed

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

Libraryless. Click here for Pure Java version (3168L/17K).

static O[] primitiveArrayToBoxed(O a) {
  if (a == null) null;
  if (a cast int[]) {
    int n = a.length;
    Int[] b = new[n];
    for i to n: b[i] = a[i];
    ret b;
  }
  if (a cast char[]) {
    int n = a.length;
    Char[] b = new[n];
    for i to n: b[i] = a[i];
    ret b;
  }
  if (a cast bool[]) {
    int n = a.length;
    Bool[] b = new[n];
    for i to n: b[i] = a[i];
    ret b;
  }
  if (a cast short[]) {
    int n = a.length;
    Short[] b = new[n];
    for i to n: b[i] = a[i];
    ret b;
  }
  if (a cast long[]) {
    int n = a.length;
    Long[] b = new[n];
    for i to n: b[i] = a[i];
    ret b;
  }
  if (a cast float[]) {
    int n = a.length;
    Float[] b = new[n];
    for i to n: b[i] = a[i];
    ret b;
  }
  if (a cast double[]) {
    int n = a.length;
    Double[] b = new[n];
    for i to n: b[i] = a[i];
    ret b;
  }
  fail("Not a primitive array: " + _getClass(a));
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1031245
Snippet name: primitiveArrayToBoxed
Eternal ID of this version: #1031245/1
Text MD5: bfec3699ccb64bba4dd919faf79bcc35
Transpilation MD5: c20f021e164e76eccd774a719fcddc74
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-25 17:19:22
Source code size: 949 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 148 / 214
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)