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()); }
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()); }