@Test void serializationTest() { Bitvector bitvector = createBitvector(); Bytes bitvectorSerialized = bitvector.serialize(); Assertions.assertEquals(bitvectorSerialized.toHexString(), "0x09"); }
@SuppressWarnings("NarrowingCompoundAssignment") public Bytes serialize() { byte[] array = new byte[sszSerializationLength(size)]; IntStream.range(0, size).forEach(i -> array[i / 8] |= ((data.get(i) ? 1 : 0) << (i % 8))); return Bytes.wrap(array); }
Bitvector { @SuppressWarnings("NarrowingCompoundAssignment") public Bytes serialize() { byte[] array = new byte[sszSerializationLength(size)]; IntStream.range(0, size).forEach(i -> array[i / 8] |= ((data.get(i) ? 1 : 0) << (i % 8))); return Bytes.wrap(array); } }
Bitvector { @SuppressWarnings("NarrowingCompoundAssignment") public Bytes serialize() { byte[] array = new byte[sszSerializationLength(size)]; IntStream.range(0, size).forEach(i -> array[i / 8] |= ((data.get(i) ? 1 : 0) << (i % 8))); return Bytes.wrap(array); } Bitvector(int size);  Bitvector(BitSet bitSet, int size);  Bitvector(Bitvector bitvector);  Bitvector(Iterable<Integer> indicesToSet, int size); }
Bitvector { @SuppressWarnings("NarrowingCompoundAssignment") public Bytes serialize() { byte[] array = new byte[sszSerializationLength(size)]; IntStream.range(0, size).forEach(i -> array[i / 8] |= ((data.get(i) ? 1 : 0) << (i % 8))); return Bytes.wrap(array); } Bitvector(int size);  Bitvector(BitSet bitSet, int size);  Bitvector(Bitvector bitvector);  Bitvector(Iterable<Integer> indicesToSet, int size); List<Integer> getSetBitIndexes(); void setBit(int i); void setBits(int... indexes); void clearBit(int i); int getBitCount(); boolean getBit(int i); int getSize(); IntStream streamAllSetBits(); @SuppressWarnings("NarrowingCompoundAssignment") Bytes serialize(); static Bitvector fromBytes(Bytes bytes, int size); static int sszSerializationLength(final int size); Bitvector rightShift(int i); Bitvector copy(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
Bitvector { @SuppressWarnings("NarrowingCompoundAssignment") public Bytes serialize() { byte[] array = new byte[sszSerializationLength(size)]; IntStream.range(0, size).forEach(i -> array[i / 8] |= ((data.get(i) ? 1 : 0) << (i % 8))); return Bytes.wrap(array); } Bitvector(int size);  Bitvector(BitSet bitSet, int size);  Bitvector(Bitvector bitvector);  Bitvector(Iterable<Integer> indicesToSet, int size); List<Integer> getSetBitIndexes(); void setBit(int i); void setBits(int... indexes); void clearBit(int i); int getBitCount(); boolean getBit(int i); int getSize(); IntStream streamAllSetBits(); @SuppressWarnings("NarrowingCompoundAssignment") Bytes serialize(); static Bitvector fromBytes(Bytes bytes, int size); static int sszSerializationLength(final int size); Bitvector rightShift(int i); Bitvector copy(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }