Here you can find the source of setBit(int[] x, int i, int v)
Parameter | Description |
---|---|
x | int array |
i | offset |
v | if odd, set; else, clear |
public static void setBit(int[] x, int i, int v)
//package com.java2s; // it under the terms of the GNU Lesser General Public License as published public class Main { /**// w ww . ja v a 2 s .c om * Used to set or clear a bit in an int array * @param x int array * @param i offset * @param v if odd, set; else, clear */ public static void setBit(int[] x, int i, int v) { if ((v & 0x01) == 1) x[i / 32] |= 1 << (i % 32); // set bit else x[i / 32] &= ~(1 << (i % 32)); // clear bit } }