IntDeltaCompressor (@NotNull IntList deltaList) { if (deltaList.size() < 0) throw new NegativeArraySizeException("size < 0: " + deltaList.size()); int bytesAfterCompression = ByteArrayUtils.countBytesAfterCompression(deltaList); Flags startedDeltaIndex = new BitSetFlags(bytesAfterCompression); byte[] compressedDeltas = new byte[bytesAfterCompression]; int currentStartIndex = 0; for (int i = 0; i < deltaList.size(); i++) { startedDeltaIndex.set(currentStartIndex, true); int value = deltaList.get(i); int sizeOf = ByteArrayUtils.sizeOf(value); ByteArrayUtils.writeDelta(currentStartIndex, value, sizeOf, compressedDeltas); currentStartIndex += sizeOf; } return new IntDeltaCompressor(compressedDeltas, startedDeltaIndex, deltaList.size()); }