public static boolean anyUnSet(MemoryBuffer bitmapBuffer, int baseOffset, int valueCount) {
    final int sizeInBytes = (valueCount + 7) / 8;
    // If value count is not a multiple of 8, then calculate number of used bits in the last byte
    final int remainder = valueCount % 8;

    final int sizeInBytesMinus1 = sizeInBytes - 1;
    int bytesMinus1EndOffset = baseOffset + sizeInBytesMinus1;
    for (int i = baseOffset; i < bytesMinus1EndOffset; i++) {
      if (bitmapBuffer.getByte(i) != (byte) 0xFF) {
        return true;
      }
    }

    // handling with the last byte
    // since unsafe putLong use native byte order, maybe not big endian,
    // see java.nio.DirectByteBuffer.putLong(long, long), we can't use unsafe.putLong
    // for bit operations, native byte order may be subject to change between machine,
    // so we use getByte
    if (remainder != 0) {
      byte byteValue = bitmapBuffer.getByte(baseOffset + sizeInBytesMinus1);
      // Every byte is set form right to left
      byte mask = (byte) (0xFF >>> (8 - remainder));
      return byteValue != mask;
    }

    return false;
  }
@Test
  public void anyUnSet() {
    int valueCount = 10;
    MemoryBuffer buffer = MemoryUtils.buffer(valueCount);
    int i = 0;
    BitUtils.set(buffer, 0, i++);
    BitUtils.set(buffer, 0, i++);
    BitUtils.set(buffer, 0, i++);
    BitUtils.set(buffer, 0, i++);
    BitUtils.set(buffer, 0, i++);
    BitUtils.set(buffer, 0, i++);
    BitUtils.set(buffer, 0, i++);
    BitUtils.set(buffer, 0, i++);
    BitUtils.set(buffer, 0, i++);
    BitUtils.set(buffer, 0, i++);
    assertFalse(BitUtils.anyUnSet(buffer, 0, valueCount));
    StringUtils.encodeHexString(buffer.getRemainingBytes());
  }