Java Utililty Methods Array Shift

List of utility methods to do Array Shift

Description

The list of methods to do Array Shift are organized into topic(s).

Method

voidshiftOffsets(int[] offsets, int changeOffset, int oldLength, int newLength)
shift Offsets
if (offsets == null)
    return;
int shift = newLength - oldLength;
if (shift == 0)
    return;
for (int i = 0; i < offsets.length; i++) {
    int offset = offsets[i];
    if (offset >= changeOffset + oldLength) {
...
double[][]shiftOnRow(double[][] d, int q)
shift On Row
double[][] ret = new double[d.length][d[0].length];
if (q >= 0) {
    for (int i = 0; i < d.length; i++) {
        for (int j = q; j < d[0].length; j++) {
            ret[i][j] = d[i][j - q];
} else {
...
voidshiftRight(byte[] block)
shift Right
int i = 0;
int bit = 0;
for (;;) {
    int b = block[i] & 0xff;
    block[i] = (byte) ((b >>> 1) | bit);
    if (++i == 16) {
        break;
    bit = (b & 1) << 7;
byteshiftRight(byte[] x)
shift Right
int i = 0, c = 0;
do {
    int b = x[i] & 0xff;
    x[i++] = (byte) ((b >>> 1) | c);
    c = (b & 1) << 7;
    b = x[i] & 0xff;
    x[i++] = (byte) ((b >>> 1) | c);
    c = (b & 1) << 7;
...
int[]shiftRight(int[] result, int[] vec, int shift)
shift Right
for (int i = 0; i < result.length; i++) {
    result[i] = vec[i] >> shift;
return result;
intshiftRight(int[] x)
shift Right
int b = x[0];
x[0] = b >>> 1;
int c = b << 31;
b = x[1];
x[1] = (b >>> 1) | c;
c = b << 31;
b = x[2];
x[2] = (b >>> 1) | c;
...
voidshiftRight(Object[] array, final int amount)
Shift array given number of times
for (int j = 0; j < amount; j++) {
    final Object temp = array[array.length - 1];
    int index;
    for (index = array.length - 1; index > 0; index--) {
        array[index] = array[index - 1];
    array[index] = temp;
voidshiftRight(T[] array)
shift Right
for (int i = 1; i < array.length; i++) {
    array[i] = array[i - 1];
array[0] = null;
voidshiftRight2(T[] array, int to)
shift Right
shiftRight3(array, 0, to);
voidshiftRightN(int[] block, int n)
shift Right N
int i = 0;
int bits = 0;
for (;;) {
    int b = block[i];
    block[i] = (b >>> n) | bits;
    if (++i == 4) {
        break;
    bits = b << (32 - n);