private void MoveSuffix(char sym, int boundIdx, int idx, HashedSet <int> newBoundarySuffix) { int curLcp = lcp[idx]; int rightBound = BinarySearch.BinarySearch.Instance.BinarySearchLast(idx, Math.Min(arrayLength - 1, 1 + idx + charCollector.GetInt(stringBuilder[boundIdx])), new LcpFirstStrategy(this, curLcp, idx)) + 1; int newPosition = BinarySearch.BinarySearch.Instance.BinarySearchFirst(idx + 1, Math.Min(rightBound + 1, arrayLength), new SymbolFirstStrategy(this, curLcp, sym)) - 1; if (idx > 0) { int lc = lcp.Aggregate(idx - 1, idx); lcp[idx - 1] = lc; } int newLcp; int newLcpPrev; if (lcp[newPosition] >= curLcp) { newLcp = curLcp; newLcpPrev = curLcp; if (stringBuilder[array[newPosition + 1] + curLcp] == sym) { newBoundarySuffix.Add(boundIdx); newLcp++; } } else { newLcp = lcp[newPosition]; newLcpPrev = curLcp; if (stringBuilder[array[newPosition] + curLcp] == sym) { newLcpPrev++; } } lcp.Move(idx, newPosition); array.Move(idx, newPosition); lcp[newPosition] = newLcp; lcp[newPosition - 1] = newLcpPrev; }
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); } }