public static List <string> GetAllMatches(string input, PalindromeSearch inputPalindromes, string pattern)
        {
            var palindromes = new List <string>();

            int[] prefixArray = ComputePrefixFunction(pattern);
            int   q           = 0;

            for (int i = 0; i < input.Length; i++)
            {
                while (q > 0 && pattern[q] != input[i])
                {
                    q = prefixArray[q - 1];
                }
                if (pattern[q] == input[i])
                {
                    ++q;
                }
                if (q == pattern.Length)
                {
                    palindromes.Add(BuildString(pattern, inputPalindromes.PalindromesAfter[i + 1], ReverseString(pattern)));                   //add palindrome form next position
                    palindromes.Add(BuildString(ReverseString(pattern), inputPalindromes.PalindromesBefore[i - pattern.Length + 1], pattern)); //add palindrome form previous position

                    q = prefixArray[q - 1];
                }
            }
            return(palindromes);
        }
        private List <string> GetPalindromes(string input, PalindromeSearch inputPalindromes, string pattern)
        {
            var palindromes = new List <string>();
            var matches     = ModifiedKnuthMorrisPrath.GetAllMatches(input, inputPalindromes, pattern);

            palindromes.AddRange(matches);
            return(palindromes);
        }
 public BuildingPalindromes(string first, string second)
 {
     allPalindromes    = new List <string>();
     this.first        = first;
     firstPalindromes  = new PalindromeSearch(first);
     this.second       = second;
     secondPalindromes = new PalindromeSearch(second);
 }