class Bitlist {

  public static Bitlist fromBytes(Bytes bytes, long maxSize) {
    int numBytes = bytes.size();
    checkArgument(numBytes > 0, "Bitlist must contain at least one byte");
    checkArgument(bytes.get(numBytes - 1) != 0, "Bitlist data must contain end marker bit");
    int leadingBitIndex = 0;
    while ((bytes.get(numBytes - 1) >>> (7 - leadingBitIndex)) % 2 == 0) {
      leadingBitIndex++;
    }

    int bitlistSize = (7 - leadingBitIndex) + (8 * (numBytes - 1));
    BitSet byteArray = new BitSet(bitlistSize);

    for (int i = bitlistSize - 1; i >= 0; i--) {
      if (((bytes.get(i / 8) >>> (i % 8)) & 0x01) == 1) {
        byteArray.set(i);
      }
    }

    return new Bitlist(bitlistSize, byteArray, maxSize);
  }

  public  Bitlist(int arraySize, long maxSize);
  public  Bitlist(Bitlist bitlist);
  private  Bitlist(int size, BitSet data, long maxSize);

}