Created
June 20, 2019 12:25
-
-
Save kaspernielsen/62e4eedffdb395228777925551a45e7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String toString(int[] a) { | |
int iMax = a.length - 1; | |
if (iMax == -1) | |
return "[]"; | |
int size = 2 * a.length; | |
for (int j = 0; j < a.length; j++) { | |
size += stringSize(a[j]); | |
} | |
if (COMPACT_STRINGS) { | |
byte[] buf = new byte[size]; | |
buf[0] = '['; | |
int c = 1; | |
for (int i = 0; ; i++) { | |
int e = a[i]; | |
c += stringSize(e); | |
getChars(e, c, buf); | |
if (i == iMax) { | |
buf[size-1] = ']'; | |
return new String(buf, LATIN1); | |
} | |
buf[c++] = ','; | |
buf[c++] = ' '; | |
} | |
} else { | |
//TODO implement | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment