SmartDeltaCompressor (@NotNull IntList deltaList) { if (deltaList.size() < 0) throw new NegativeArraySizeException("size < 0: " + deltaList.size()); int bytesAfterCompression = countBytesAfterCompression(deltaList); byte[] deltas = new byte[bytesAfterCompression]; int size = deltaList.size(); int groundPointCount = groundPointCount(size, 64); int[] groundIndexes = new int[groundPointCount]; long[] majorBits = new long[groundPointCount]; long[] minorBits = new long[groundPointCount]; int offset = 0; for (int main = 0; main < groundPointCount; main++) { groundIndexes[main] = offset; for (int rem = 0; rem < 64; rem++) { int index = main * 64 + rem; if (index >= size) break; int sizeOf = sizeOf(deltaList.get(index)); writeDelta(offset, deltaList.get(index), sizeOf, deltas); long mask = 1L << rem; /* 4 -> 11 3 -> 10 2 -> 01 1 -> 00 */ if (sizeOf == 3 || sizeOf == 4) majorBits[main] |= mask; if (sizeOf == 2 || sizeOf == 4) minorBits[main] |= mask; offset += sizeOf; } } return new SmartDeltaCompressor(size, deltas, majorBits, minorBits, groundIndexes); }