public void writeMixed(final int v) throws IOException {
        if (v != lastValue && repCount > 0) {
            int d = lastValue - lastLastValue;
            lastLastValue = lastValue;

            encodeBit(d < 0);
            if (d < 0) {
                d = -d;
            }
            encodeVarBits(d - diffshift);
            encodeVarBits(repCount - 1);

            if (d < 100) {
                diffs[d]++;
            }
            if (repCount < 100) {
                counts[repCount]++;
            }

            diffshift = 1;
            repCount = 0;
        }
        lastValue = v;
        repCount++;
    }
DataOutputStream for fast-compact encoding of number sequences

@author ab
main/src/main/java/cgeo/geocaching/brouter/util/MixCoderDataOutputStream.java