コード例 #1
0
 public void checkEncodeSimple()
 {
     DeltaZigzagEncoding.Encoder e = new DeltaZigzagEncoding.Encoder(0);
     checkEncode(e,
                 new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
                 new int[] { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2 });
 }
コード例 #2
0
 private static void checkEncode(
     DeltaZigzagEncoding.Encoder e,
     int[] data,
     int[] expected)
 {
     Assert2.assertArrayEquals(expected, e.encodeArray(data));
     Assert2.assertEquals(data[data.Length - 1], e.getContextValue());
 }
コード例 #3
0
 public void checkZigzagEncode()
 {
     DeltaZigzagEncoding.Encoder e = new DeltaZigzagEncoding.Encoder(0);
     Assert2.assertEquals(0, zigzagEncode(e, 0));
     Assert2.assertEquals(2, zigzagEncode(e, 1));
     Assert2.assertEquals(4, zigzagEncode(e, 2));
     Assert2.assertEquals(6, zigzagEncode(e, 3));
     Assert2.assertEquals(1, zigzagEncode(e, -1));
     Assert2.assertEquals(3, zigzagEncode(e, -2));
     Assert2.assertEquals(5, zigzagEncode(e, -3));
 }
コード例 #4
0
        public void compress(int[] inBuf, IntWrapper inPos, int inLen, int[] outBuf, IntWrapper outPos)
        {
            inLen = inLen - inLen % BLOCK_LENGTH;
            if (inLen == 0)
            {
                return;
            }

            outBuf[outPos.get()] = inLen;
            outPos.increment();

            DeltaZigzagEncoding.Encoder ctx = new DeltaZigzagEncoding.Encoder(0);
            int[] work = new int[BLOCK_LENGTH];

            int op        = outPos.get();
            int ip        = inPos.get();
            int inPosLast = ip + inLen;

            for (; ip < inPosLast; ip += BLOCK_LENGTH)
            {
                ctx.encodeArray(inBuf, ip, BLOCK_LENGTH, work);
                int bits1 = Util.maxbits32(work, 0);
                int bits2 = Util.maxbits32(work, 32);
                int bits3 = Util.maxbits32(work, 64);
                int bits4 = Util.maxbits32(work, 96);
                outBuf[op++] = (bits1 << 24) | (bits2 << 16)
                               | (bits3 << 8) | (bits4 << 0);
                op += pack(work, 0, outBuf, op, bits1);
                op += pack(work, 32, outBuf, op, bits2);
                op += pack(work, 64, outBuf, op, bits3);
                op += pack(work, 96, outBuf, op, bits4);
            }

            inPos.add(inLen);
            outPos.set(op);
        }
コード例 #5
0
 private static int zigzagEncode(DeltaZigzagEncoding.Encoder e, int value)
 {
     e.setContextValue(0);
     return(e.encodeInt(value));
 }