SizeOf.SIZE_OF_SHORT + // number of short hashes
SizeOf.SIZE_OF_SHORT + // number of overflow entries
SizeOf.SIZE_OF_SHORT * numberOfHashes + //
SizeOf.SIZE_OF_SHORT * numberOfOverflows;
DynamicSliceOutput out = new DynamicSliceOutput(size)
.appendByte(Format.SPARSE_V1.getTag())
.appendByte(indexBitLength)
.appendShort(numberOfHashes)
.appendShort(numberOfOverflows);
for (int i = 0; i < numberOfHashes; i++) {
out.appendShort(shortHashes[i]);
}
for (int i = 0; i < numberOfOverflows; i++) {
out.appendShort(overflows[i]);
}
return out.slice();
}