Exemplo n.º 1
0
 private void UpdateCharCollector(string str)
 {
     foreach (char c in str)
     {
         CharCollector.AddChar(c);
     }
 }
Exemplo n.º 2
0
        private void MoveSuffix(int boundSuffix, int idx, ZAlgorithm zAlgorithm, int index, string str, HashedSet <int> newBoundarySuffix)
        {
            int first = BinarySearch.BinarySearch.Instance.BinarySearchFirst(idx + 1,
                                                                             Math.Min(ArrayLength + 1, idx + 1 + CharCollector.GetInt(String[boundSuffix])),
                                                                             new BlockSuffixArrayStrategy(this, idx, zAlgorithm, index)) - 1;

            if (idx > 0)
            {
                Lcp[idx - 1] = Math.Min(Lcp[idx], Lcp[idx - 1]);
            }

            CompareResult compare1 = Compare(idx, first, zAlgorithm, index);

            CompareResult compare2;

            if (first == ArrayLength - 1)
            {
                compare2 = new CompareResult(1, 0);
            }
            else
            {
                compare2 = Compare(idx, first + 1, zAlgorithm, index);
            }

            Array.Move(idx, first);
            Lcp.Move(idx, first);
            Lcp[first - 1] = compare1.Lcp;
            Lcp[first]     = compare2.Lcp;

            //boundary support
            if (compare2.Lcp == str.Length + ArrayLength - Array[first])
            {
                newBoundarySuffix.Add(boundSuffix);
            }
        }