src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/FuzzyMatching.cs
/// <summary>
/// Gets all the possible matches to the search string with in the text
/// </summary>
/// <param name="matches"> a table showing the matches as generated by
/// a two dimensional array with the first dimension the text and the second
/// one the search string and each cell marked as an intersection between the two</param>
/// <returns>a list of the possible combinations that match the search text</returns>
Gets all the possible matches to the search string with in the text
Gets all the possible matches to the search string with in the text
public static List<List<int>> GetAllMatchIndexes(bool[,] matches)
        {
            List<List<int>> results = new List<List<int>>();
            for (int secondIndex = 0; secondIndex < matches.GetLength(1); secondIndex++)
            {
                for (int firstIndex = 0; firstIndex < matches.GetLength(0); firstIndex++)
                {
                    if (secondIndex == 0 && matches[firstIndex, secondIndex])
                    {
                        results.Add(new List<int> { firstIndex });
                    }
                    else if (matches[firstIndex, secondIndex])
                    {
                        var tempList = results.Where(x => x.Count == secondIndex && x[x.Count - 1] < firstIndex).Select(x => x.ToList()).ToList();
                        foreach (var pathSofar in tempList)
                        {
                            pathSofar.Add(firstIndex);
                        }
                        results.AddRange(tempList);
                    }
                }
                results = results.Where(x => x.Count == secondIndex + 1).ToList();
            }
            return results.Where(x => x.Count == matches.GetLength(1)).ToList();
        }
public static List < List < int > > GetAllMatchIndexes ( bool [ , ] matches ) { List < List < int > > results = new List < List < int > > ( ) ; for ( int secondIndex = 0 ; secondIndex < matches . GetLength ( 1 ) ; secondIndex ++ ) { for ( int firstIndex = 0 ; firstIndex < matches . GetLength ( 0 ) ; firstIndex ++ ) { if ( secondIndex == 0 && matches [ firstIndex , secondIndex ] ) { results . Add ( new List < int > { firstIndex } ) ; } else if ( matches [ firstIndex , secondIndex ] ) { var tempList = results . Where ( x => x . Count == secondIndex && x [ x . Count - 1 ] < firstIndex ) . Select ( x => x . ToList ( ) ) . ToList ( ) ; foreach ( var pathSofar in tempList ) { pathSofar . Add ( firstIndex ) ; } results . AddRange ( tempList ) ; } } results = results . Where ( x => x . Count == secondIndex + 1 ) . ToList ( ) ; } return results . Where ( x => x . Count == matches . GetLength ( 1 ) ) . ToList ( ) ; }
Gets all the possible matches to the search string with in the text
Gets all the possible matches to the search string with in the text
a list of the possible combinations that match the search text
a list of the possible combinations that match the search text
matches
bool[,]
a table showing the matches as generated by
a two dimensional array with the first dimension the text and the second
one the search string and each cell marked as an intersection between the two
a table showing the matches as generated by a two dimensional array with the first dimension the text and the second one the search string and each cell marked as an intersection between the two