Ejemplo n.º 1
0
 public static void Handle(byte[] Input, int MinSearchSize, int MaxSearchSize, int MaxDistance, bool AllowOverlapping, Action<int, int, int> Callback)
 {
     var LzBuffer = new LzBuffer(MinSearchSize);
     LzBuffer.AddBytes(Input);
     for (int n = 0; n < Input.Length;)
     {
         var Result = LzBuffer.FindMaxSequence(n, n, MaxDistance, MinSearchSize, MaxSearchSize, AllowOverlapping);
         if (Result.Found)
         {
             Callback(n, Result.Offset - n, Result.Size);
             n += Result.Size;
         }
         else
         {
             Callback(n, 0, 0);
             n++;
         }
     }
 }
Ejemplo n.º 2
0
        static public void Handle(byte[] Input, int MinSearchSize, int MaxSearchSize, int MaxDistance, bool AllowOverlapping, Action <int, int, int> Callback)
        {
            var LzBuffer = new LzBuffer(MinSearchSize);

            LzBuffer.AddBytes(Input);
            for (int n = 0; n < Input.Length;)
            {
                var Result = LzBuffer.FindMaxSequence(n, n, MaxDistance, MinSearchSize, MaxSearchSize, AllowOverlapping);
                if (Result.Found)
                {
                    Callback(n, Result.Offset - n, Result.Size);
                    n += Result.Size;
                }
                else
                {
                    Callback(n, 0, 0);
                    n++;
                }
            }
        }
Ejemplo n.º 3
0
        public void FindMaxSequenceTest()
        {
            LzBuffer LzBuffer = new LzBuffer(3);
            LzBuffer.AddBytes(new byte[] {
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
                7, 8, 9, 10, 12, 13,
                7, 8, 9, 10, 11, 16
            });

            var Result = LzBuffer.FindMaxSequence(
                LzBuffer.Size - 6,
                LzBuffer.Size - 6,
                0x1000,
                3,
                16,
                true
            );

            Assert.AreEqual("LzBuffer.FindSequenceResult(Offset=7, Size=5)", Result.ToString());
        }