public static byte[] Transform(byte[] input)
        {
            byte[]  output   = new byte[input.Length + 4];
            short[] newInput = new short[input.Length + 1];

            for (int i = 0; i < input.Length; i++)
            {
                newInput[i] = (Int16)(input[i] + 1);
            }

            newInput[input.Length] = 0;
            int[] suffixArray = SuffixArray.Construct(newInput);
            int   end         = 0;
            int   outputInd   = 0;

            for (int i = 0; i < suffixArray.Length; i++)
            {
                if (suffixArray[i] == 0)
                {
                    end = i;
                    continue;
                }
                output[outputInd] = (byte)(newInput[suffixArray[i] - 1] - 1);
                outputInd++;
            }
            byte[] endByte = IntToByteArr(end);
            endByte.CopyTo(output, input.Length);
            return(output);
        }
Beispiel #2
0
 public void ConstructTest()
 {
     int[] suffix1 = SuffixArray.Construct(StringToShortArr(input1));
     int[] suffix2 = SuffixArray.Construct(StringToShortArr(input2));
     CollectionAssert.AreEqual(output1, suffix1);
     CollectionAssert.AreEqual(output2, suffix2);
 }