public static void idx( final char[] array, int index, char value ) { final int i = calculateIndex( array, index ); array[ i ] = value; }
public static char idx( final char[] array, final int index ) { final int i = calculateIndex( array, index ); return array[ i ]; }
public static void idx( final char[] array, int index, char value ) { final int i = calculateIndex( array, index ); array[ i ] = value; }
public static char idx( final char[] array, final int index ) { final int i = calculateIndex( array, index ); return array[ i ]; }
public static char[] slc( char[] array, int startIndex ) { final int start = calculateIndex( array, startIndex ); final int newLength = array.length - start; if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "start index %d, length %d", startIndex, array.length ) ); } char[] newArray = new char[ newLength ]; arraycopy(array, start, newArray, 0, newLength); return newArray; }
public static char[] slc( char[] array, int startIndex ) { final int start = calculateIndex( array, startIndex ); final int newLength = array.length - start; if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "start index %d, length %d", startIndex, array.length ) ); } char[] newArray = new char[ newLength ]; arraycopy(array, start, newArray, 0, newLength); return newArray; }
public static void idx( final char[] array, int index, char[] input ) { final int i = calculateIndex( array, index ); _idx( array, i, input ); }
public static char[] slc( char[] array, int startIndex, int endIndex ) { final int start = calculateIndex( array, startIndex ); final int end = calculateEndIndex( array, endIndex ); int newLength = end - start; if ( newLength < 0 ) { return EMPTY_CHARS; } char[] newArray = new char[ newLength ]; arraycopy(array, start, newArray, 0, newLength); return newArray; }
public static char[] slc( char[] array, int startIndex, int endIndex ) { final int start = calculateIndex( array, startIndex ); final int end = calculateEndIndex( array, endIndex ); int newLength = end - start; if ( newLength < 0 ) { return EMPTY_CHARS; } char[] newArray = new char[ newLength ]; arraycopy(array, start, newArray, 0, newLength); return newArray; }
public static void idx( final char[] array, int index, char[] input ) { final int i = calculateIndex( array, index ); _idx( array, i, input ); }
public static char[] insert( final char[] array, final int idx, final char v ) { Exceptions.requireNonNull( array ); if ( idx >= array.length ) { return add( array, v ); } final int index = calculateIndex( array, idx ); //Object newArray = Array.newInstance(array.getClass().getComponentType(), array.length+1); char[] newArray = new char[ array.length + 1 ]; if ( index != 0 ) { /* Copy up to the length in the array before the index. */ /* src sbegin dst dbegin length of copy */ 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 */ arraycopy ( array, index, newArray, index + 1, remainingIndex ); } else { /* Copy the area after the insert. */ /* src sbegin dst dbegin length of copy */ arraycopy ( array, index, newArray, index + 1, remainingIndex ); } newArray[ index ] = v; return newArray; }
public static char[] insert( final char[] array, final int fromIndex, final char[] values ) { Exceptions.requireNonNull( array ); if ( fromIndex >= array.length ) { return add( array, values ); } final int index = calculateIndex( array, fromIndex ); //Object newArray = Array.newInstance(array.getClass().getComponentType(), array.length+1); char[] newArray = new char[ 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 */ 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 */ arraycopy ( array, index, newArray, index + values.length, remainingIndex ); } else { /* Copy the area after the insert. */ /* src sbegin dst dbegin length of copy */ 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 char[] insert( final char[] array, final int fromIndex, final char[] values ) { Exceptions.requireNonNull( array ); if ( fromIndex >= array.length ) { return add( array, values ); } final int index = calculateIndex( array, fromIndex ); //Object newArray = Array.newInstance(array.getClass().getComponentType(), array.length+1); char[] newArray = new char[ 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 */ 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 */ arraycopy ( array, index, newArray, index + values.length, remainingIndex ); } else { /* Copy the area after the insert. */ /* src sbegin dst dbegin length of copy */ 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 char[] insert( final char[] array, final int idx, final char v ) { Exceptions.requireNonNull( array ); if ( idx >= array.length ) { return add( array, v ); } final int index = calculateIndex( array, idx ); //Object newArray = Array.newInstance(array.getClass().getComponentType(), array.length+1); char[] newArray = new char[ array.length + 1 ]; if ( index != 0 ) { /* Copy up to the length in the array before the index. */ /* src sbegin dst dbegin length of copy */ 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 */ arraycopy ( array, index, newArray, index + 1, remainingIndex ); } else { /* Copy the area after the insert. */ /* src sbegin dst dbegin length of copy */ arraycopy ( array, index, newArray, index + 1, remainingIndex ); } newArray[ index ] = v; return newArray; }