Java Array Shift ShiftLeftOne(int[] arr)

Here you can find the source of ShiftLeftOne(int[] arr)

Description

Shift Left One

License

Creative Commons License

Declaration

static int ShiftLeftOne(int[] arr) 

Method Source Code

//package com.java2s;

public class Main {
    static int ShiftLeftOne(int[] arr) {
        {//from  ww w.  ja  va 2 s  . c  om
            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;
        }
    }
}

Related

  1. shiftLeft1(T[] array)
  2. shiftLeftAndFill(byte[] array, int positions)
  3. shiftLeftByCopying(int[] table, int shift)
  4. shiftLeftByOne(int[] table)
  5. shiftLeftI(long[] v, int off)
  6. shiftNibbles(byte[] bytes)
  7. shiftOff(T[] a)
  8. shiftOffsets(int[] offsets, int changeOffset, int oldLength, int newLength)
  9. shiftOnRow(double[][] d, int q)