public boolean getBit(int bitIndex) { int index = bitIndex / 8; int shift = bitIndex % 8; int value = get(index); // Return true if the bit pointed to by bitIndex is set. return ((value & (1 << shift)) != 0); }
private static int skipPlainBlock(ByteArray input, int[] bitIndex) { // 3.2.4 Non-compressed blocks (BTYPE=00) // Skip any remaining bits in current partially processed byte. int bi = (bitIndex[0] + 7) & ~7; // Data copy is performed on a byte basis, so convert the bit index // to a byte index. int index = bi / 8; // LEN: 2 bytes. The data length. int len = (input.get(index) & 0xFF) + (input.get(index + 1) & 0xFF) * 256; // NLEN: 2 bytes. The one's complement of LEN. // Skip LEN and NLEN. index += 4; // Make the bitIndex point to the bit next to // the end of the copied data. bitIndex[0] = (index + len) * 8; return len; }
public void setBit(int bitIndex, boolean bit) { int index = bitIndex / 8; int shift = bitIndex % 8; int value = get(index); if (bit) { value |= (1 << shift); } else { value &= ~(1 << shift); } mBuffer.put(index, (byte)value); }
private static void inflatePlainBlock(ByteArray input, int[] bitIndex, ByteArray output) { // 3.2.4 Non-compressed blocks (BTYPE=00) // Skip any remaining bits in current partially processed byte. int bi = (bitIndex[0] + 7) & ~7; // Data copy is performed on a byte basis, so convert the bit index // to a byte index. int index = bi / 8; // LEN: 2 bytes. The data length. int len = (input.get(index) & 0xFF) + (input.get(index + 1) & 0xFF) * 256; // NLEN: 2 bytes. The one's complement of LEN. // Skip LEN and NLEN. index += 4; // Copy the data to the output. output.put(input, index, len); // Make the bitIndex point to the bit next to // the end of the copied data. bitIndex[0] = (index + len) * 8; }
target[targetIndex] = output.get(sourceIndex);
public boolean getBit(int bitIndex) { int index = bitIndex / 8; int shift = bitIndex % 8; int value = get(index); // Return true if the bit pointed to by bitIndex is set. return ((value & (1 << shift)) != 0); }
private static int skipPlainBlock(ByteArray input, int[] bitIndex) { // 3.2.4 Non-compressed blocks (BTYPE=00) // Skip any remaining bits in current partially processed byte. int bi = (bitIndex[0] + 7) & ~7; // Data copy is performed on a byte basis, so convert the bit index // to a byte index. int index = bi / 8; // LEN: 2 bytes. The data length. int len = (input.get(index) & 0xFF) + (input.get(index + 1) & 0xFF) * 256; // NLEN: 2 bytes. The one's complement of LEN. // Skip LEN and NLEN. index += 4; // Make the bitIndex point to the bit next to // the end of the copied data. bitIndex[0] = (index + len) * 8; return len; }
public void setBit(int bitIndex, boolean bit) { int index = bitIndex / 8; int shift = bitIndex % 8; int value = get(index); if (bit) { value |= (1 << shift); } else { value &= ~(1 << shift); } mBuffer.put(index, (byte)value); }
private static void inflatePlainBlock(ByteArray input, int[] bitIndex, ByteArray output) { // 3.2.4 Non-compressed blocks (BTYPE=00) // Skip any remaining bits in current partially processed byte. int bi = (bitIndex[0] + 7) & ~7; // Data copy is performed on a byte basis, so convert the bit index // to a byte index. int index = bi / 8; // LEN: 2 bytes. The data length. int len = (input.get(index) & 0xFF) + (input.get(index + 1) & 0xFF) * 256; // NLEN: 2 bytes. The one's complement of LEN. // Skip LEN and NLEN. index += 4; // Copy the data to the output. output.put(input, index, len); // Make the bitIndex point to the bit next to // the end of the copied data. bitIndex[0] = (index + len) * 8; }
target[targetIndex] = output.get(sourceIndex);