List of utility methods to do Array Shift
void | shiftLeft(Object[] array, int amount) shift Left Object[] temp = array.clone(); for (int i = 0; i < array.length; i++) { array[(i - amount + array.length) % array.length] = temp[i]; |
Object[] | shiftLeft(Object[] object) shift Left if (object.length == 0) { return new Object[0]; Object ret[] = new Object[object.length - 1]; for (int i = 0; i < ret.length; i++) { ret[i] = object[i + 1]; return ret; ... |
void | shiftLeft1(T[] array) shift Left for (int i = 0; i < array.length - 1; i++) { array[i] = array[i + 1]; array[array.length - 1] = null; |
byte[] | shiftLeftAndFill(byte[] array, int positions) Shift byte array a certain number of positions to left (where the minus significant bit is at the right end), and fill with 0's as the array is moved. if (array == null) throw new IllegalArgumentException("Cannot shift a null byte array"); if (positions < 0) throw new IllegalArgumentException("Cannot shift a negative number of positions"); if (positions >= 8) throw new IllegalArgumentException( "Weird error, should not be asking for shifting more than 7 positions, but " + positions + " are asked for"); ... |
int[] | shiftLeftByCopying(int[] table, int shift) shift Left By Copying int[] shiftedArray = new int[table.length]; System.arraycopy(table, shift, shiftedArray, 0, table.length - shift); System.arraycopy(table, 0, shiftedArray, table.length - shift, shift); return shiftedArray; |
void | shiftLeftByOne(int[] table) shift Left By One int firstElement = table[0]; for (int index = 0; index < table.length - 1; index++) { table[index] = table[index + 1]; table[table.length - 1] = firstElement; |
long[] | shiftLeftI(long[] v, int off) Shift a long[] bitset inplace. if (off == 0) { return v; if (off < 0) { return shiftRightI(v, -off); final int shiftWords = off >>> LONG_LOG2_SIZE; final int shiftBits = off & LONG_LOG2_MASK; ... |
int | ShiftLeftOne(int[] arr) Shift Left One int carry = 0; for (int i = 0; i < arr.length; ++i) { int item = arr[i]; arr[i] = (int) (arr[i] << 1) | (int) carry; carry = ((item >> 31) != 0) ? 1 : 0; return carry; ... |
byte[] | shiftNibbles(byte[] bytes) Shifts every nibble pair of every byte assert (bytes != null); assert (bytes.length > 0); byte[] bytesRet = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) bytesRet[i] = shiftNibbles(bytes[i]); return bytesRet; |
T[] | shiftOff(T[] a) shift Off return (a.length == 0 ? a : Arrays.copyOfRange(a, 1, a.length));
|