public static byte[] addChar( byte[] array, char value ) { byte[] holder = new byte[ 2 ]; charTo( holder, 0, value ); return add( array, holder ); }
public static byte[] addInt( byte[] array, int v ) { byte[] arrayToHoldInt = new byte[ 4 ]; intTo( arrayToHoldInt, 0, v ); return add( array, arrayToHoldInt ); }
public static byte[] addChar( byte[] array, char value ) { byte[] holder = new byte[ 2 ]; charTo( holder, 0, value ); return add( array, holder ); }
public static byte[] addShort( byte[] array, short value ) { byte[] holder = new byte[ 2 ]; shortTo( holder, 0, value ); return add( array, holder ); }
public static byte[] addFloat( byte[] array, float value ) { byte[] holder = new byte[ 4 ]; floatTo( holder, 0, value ); return add( array, holder ); }
public static byte[] addInt( byte[] array, int v ) { byte[] arrayToHoldInt = new byte[ 4 ]; intTo( arrayToHoldInt, 0, v ); return add( array, arrayToHoldInt ); }
public static byte[] addLong( byte[] array, long value ) { byte[] holder = new byte[ 8 ]; longTo( holder, 0, value ); return add( array, holder ); }
public static byte[] addLong( byte[] array, long value ) { byte[] holder = new byte[ 8 ]; longTo( holder, 0, value ); return add( array, holder ); }
public static byte[] addShort( byte[] array, short value ) { byte[] holder = new byte[ 2 ]; shortTo( holder, 0, value ); return add( array, holder ); }
public static byte[] addFloat( byte[] array, float value ) { byte[] holder = new byte[ 4 ]; floatTo( holder, 0, value ); return add( array, holder ); }
public static byte[] insert( final byte[] array, final int idx, final byte v ) { if ( idx >= array.length ) { return add( array, v ); } final int index = calculateIndex( array, idx ); //Object newArray = Array.newInstance(array.getClass().getComponentType(), array.length+1); byte[] newArray = new byte[ array.length + 1 ]; if ( index != 0 ) { /* Copy up to the length in the array before the index. */ /* src sbegin dst dbegin length of copy */ System.arraycopy( array, 0, newArray, 0, index ); } boolean lastIndex = index == array.length - 1; int remainingIndex = array.length - index; if ( lastIndex ) { /* Copy the area after the insert. Make sure we don't write over the end. */ /* src sbegin dst dbegin length of copy */ System.arraycopy( array, index, newArray, index + 1, remainingIndex ); } else { /* Copy the area after the insert. */ /* src sbegin dst dbegin length of copy */ System.arraycopy( array, index, newArray, index + 1, remainingIndex ); } newArray[ index ] = v; return newArray; }
public static byte[] insert( final byte[] array, final int idx, final byte v ) { if ( idx >= array.length ) { return add( array, v ); } final int index = calculateIndex( array, idx ); //Object newArray = Array.newInstance(array.getClass().getComponentType(), array.length+1); byte[] newArray = new byte[ array.length + 1 ]; if ( index != 0 ) { /* Copy up to the length in the array before the index. */ /* src sbegin dst dbegin length of copy */ System.arraycopy( array, 0, newArray, 0, index ); } boolean lastIndex = index == array.length - 1; int remainingIndex = array.length - index; if ( lastIndex ) { /* Copy the area after the insert. Make sure we don't write over the end. */ /* src sbegin dst dbegin length of copy */ System.arraycopy( array, index, newArray, index + 1, remainingIndex ); } else { /* Copy the area after the insert. */ /* src sbegin dst dbegin length of copy */ System.arraycopy( array, index, newArray, index + 1, remainingIndex ); } newArray[ index ] = v; return newArray; }
public static byte[] insert( final byte[] array, final int fromIndex, final byte[] values ) { if ( fromIndex >= array.length ) { return add( array, values ); } final int index = calculateIndex( array, fromIndex ); //Object newArray = Array.newInstance(array.getClass().getComponentType(), array.length+1); byte[] newArray = new byte[ array.length + values.length ]; if ( index != 0 ) { /* Copy up to the length in the array before the index. */ /* src sbegin dst dbegin length of copy */ System.arraycopy( array, 0, newArray, 0, index ); } boolean lastIndex = index == array.length - 1; int toIndex = index + values.length; int remainingIndex = newArray.length - toIndex; if ( lastIndex ) { /* Copy the area after the insert. Make sure we don't write over the end. */ /* src sbegin dst dbegin length of copy */ System.arraycopy( array, index, newArray, index + values.length, remainingIndex ); } else { /* Copy the area after the insert. */ /* src sbegin dst dbegin length of copy */ System.arraycopy( array, index, newArray, index + values.length, remainingIndex ); } for ( int i = index, j = 0; i < toIndex; i++, j++ ) { newArray[ i ] = values[ j ]; } return newArray; }
public static byte[] insert( final byte[] array, final int fromIndex, final byte[] values ) { if ( fromIndex >= array.length ) { return add( array, values ); } final int index = calculateIndex( array, fromIndex ); //Object newArray = Array.newInstance(array.getClass().getComponentType(), array.length+1); byte[] newArray = new byte[ array.length + values.length ]; if ( index != 0 ) { /* Copy up to the length in the array before the index. */ /* src sbegin dst dbegin length of copy */ System.arraycopy( array, 0, newArray, 0, index ); } boolean lastIndex = index == array.length - 1; int toIndex = index + values.length; int remainingIndex = newArray.length - toIndex; if ( lastIndex ) { /* Copy the area after the insert. Make sure we don't write over the end. */ /* src sbegin dst dbegin length of copy */ System.arraycopy( array, index, newArray, index + values.length, remainingIndex ); } else { /* Copy the area after the insert. */ /* src sbegin dst dbegin length of copy */ System.arraycopy( array, index, newArray, index + values.length, remainingIndex ); } for ( int i = index, j = 0; i < toIndex; i++, j++ ) { newArray[ i ] = values[ j ]; } return newArray; }
public static byte[] addDouble( byte[] array, double value ) { Exceptions.requireNonNull( array ); byte[] holder = new byte[ 4 ]; doubleTo( holder, 0, value ); return add( array, holder ); }
public static byte[] addDouble( byte[] array, double value ) { Exceptions.requireNonNull( array ); byte[] holder = new byte[ 4 ]; doubleTo( holder, 0, value ); return add( array, holder ); }