List of utility methods to do Bit Set
byte | setBitAt(int offset, boolean bitValue, byte aByte) Set a bit within a byte. return (byte) ((bitValue) ? (aByte | (1 << offset)) : (aByte & ~(1 << offset))); |
byte | setBitAt(int offset, boolean bitValue, byte aByte) set Bit At return (byte) ((bitValue) ? (aByte | (1 << offset)) : (aByte & ~(1 << offset))); |
int | setBitBiInt(int b0, int b1, int value, int original) Sets an int into another int. original = setBit(b0, getBit(0, value), original);
original = setBit(b1, getBit(1, value), original);
return original;
|
byte | setBitByPos(byte byt, boolean bool, int pos) set Bit By Pos if (bool) { return (byte) ((int) byt | mask[pos]); } else { return (byte) ((int) byt & invMask[pos]); |
int | setBitInInt(int bits, int bitIndex, boolean flag) Convenience method to set a boolean as a bit in the specified int, for memory utilisation purposes. if (bitIndex < 0 || bitIndex > 31) { throw new IllegalArgumentException(); int mask = 1 << bitIndex; return (bits & ~mask) | (flag ? mask : 0); |
long | setBitInLong(long l, long n, int v) Set bit n of a 64-bit sequence i to v (0 or 1) if (v != 0) { return l | (1L << n); } else { return l & ~(1L << n); |
void | setBitLE(byte[] data, int index) set Bit LE data[index >>> 3] |= bitMask[7 & index]; |
void | setBitmapRange(long[] bitmap, int start, int end) set bits at start, start+1,..., end-1 if (start == end) { return; int firstword = start / 64; int endword = (end - 1) / 64; if (firstword == endword) { bitmap[firstword] |= (~0L << start) & (~0L >>> -end); return; ... |
int | setBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end) set bits at start, start+1,..., end-1 and report the cardinality change int cardbefore = cardinalityInBitmapWordRange(bitmap, start, end); setBitmapRange(bitmap, start, end); int cardafter = cardinalityInBitmapWordRange(bitmap, start, end); return cardafter - cardbefore; |
int | setBitRange(final int val, final int start, final int len, final int newVal) Sets a set of bits in a int. int mask = ((1 << len) - 1) << start; return (val & ~mask) | ((newVal << start) & mask); |