/**
         * Compress an array and returns the compressed result as a new array.
         *
         * @param input array to be compressed
         * @return compressed array
         */
        public int[] compress(int[] input)
        {
            int[] compressed = new int[input.Length + 1024];
            compressed[0] = input.Length;
            IntWrapper outpos    = new IntWrapper(1);
            IntWrapper initvalue = new IntWrapper(0);

            codec.headlessCompress(input, new IntWrapper(0),
                                   input.Length, compressed, outpos, initvalue);
            compressed = Arrays.copyOf(compressed, outpos.intValue());
            return(compressed);
        }
Exemple #2
0
        public void headlessCompress(int[] @in, IntWrapper inpos, int inlength, int[] @out, IntWrapper outpos, IntWrapper initvalue)
        {
            if (inlength == 0)
            {
                return;
            }
            int init = inpos.get();

            F1.headlessCompress(@in, inpos, inlength, @out, outpos, initvalue);
            if (outpos.get() == 0)
            {
                @out[0] = 0;
                outpos.increment();
            }
            inlength -= inpos.get() - init;
            F2.headlessCompress(@in, inpos, inlength, @out, outpos, initvalue);
        }