Beispiel #1
0
        public static int[] DecodeIntDiff(string text)
        {
            CharFlow flow = new CharFlow(text.ToCharArray());
            int      sz   = Base46.DecodeUnsigned(flow);

            int[] data = new int[sz];
            int   last = 0;

            for (int i = 0; i < sz; i++)
            {
                last   += Base46.Decode(flow);
                data[i] = last;
            }
            return(data);
        }
Beispiel #2
0
        public static string EncodeIntDiff(int[] data)
        {
            StringBuilder sbr = new StringBuilder();

            Base46.EncodeUnsigned(sbr, data.Length);
            int last = 0;

            for (int i = 0; i < data.Length; i++)
            {
                int v = data[i];
                Base46.Encode(sbr, v - last);
                last = v;
            }
            return(sbr.ToString());
        }
Beispiel #3
0
        public static int[] DecodeIntPairsDiff(string text)
        {
            CharFlow flow = new CharFlow(text.ToCharArray());
            int      sz   = Base46.DecodeUnsigned(flow);

            int[] data      = new int[sz * 2];
            int   j         = 0;
            int   lastKey   = 0;
            int   lastValue = 0;

            for (int i = 0; i < sz; i++)
            {
                lastKey   += Base46.Decode(flow);
                lastValue += Base46.Decode(flow);
                data[j++]  = lastKey;
                data[j++]  = lastValue;
            }
            return(data);
        }
Beispiel #4
0
        public static string EncodeIntPairsDiff(int[] data)
        {
            StringBuilder sbr = new StringBuilder();

            Base46.EncodeUnsigned(sbr, data.Length / 2);
            int lastKey   = 0;
            int lastValue = 0;

            for (int i = 0; i < data.Length; i += 2)
            {
                int key   = data[i];
                int value = data[i + 1];
                Base46.Encode(sbr, key - lastKey);
                Base46.Encode(sbr, value - lastValue);
                lastKey   = key;
                lastValue = value;
            }
            return(sbr.ToString());
        }