Java Utililty Methods Short Number Array Create

List of utility methods to do Short Number Array Create

Description

The list of methods to do Short Number Array Create are organized into topic(s).

Method

short[]toShortArray(boolean[] array)
Coverts given booleans array to array of shorts.
short[] result = new short[array.length];
for (int i = 0; i < array.length; i++) {
    result[i] = array[i] ? (short) 1 : (short) 0;
return result;
short[]toShorts(byte[] array, int offset, int length)
Returns a short array built from a byte array.
short[] buf = new short[length / 2];
int j = 0;
for (int i = offset; i < offset + length - 1; i += 2)
    buf[j++] = (short) (((array[i] & 0xFF) << 8) | (array[i + 1] & 0xFF));
return buf;
short[]toShorts(byte[] bytes)
to Shorts
int size = toInt(bytes, 0);
short[] result = new short[size];
int offset = SIZEOF_INT;
for (int i = 0; i < size; i++) {
    result[i] = toShort(bytes, offset);
    offset += SIZEOF_SHORT;
return result;
...
short[]toShorts(byte[] readBuffer, int o, int l)
to Shorts
short[] v = new short[l / 2];
for (int i = 0; i < v.length; i++)
    v[i] = toShort(readBuffer, o + i * 2);
return v;
short[]toShorts(byte[] value, int offset, int num)
to Shorts
short[] values = new short[num];
int idx = 0;
for (int i = offset; i < offset + (num * 2); i += 2) {
    values[idx++] = getShort(value, i);
return values;
short[]toShorts(Short[] values)
to Shorts
return toShorts(values, DEFAULT_SHORT);