Beispiel #1
0
        static HashSet <string>[] DawgPrefixSearch(Dawg dawg, string[] prefixes, int times, int?max = null)
        {
            var results = new HashSet <string> [prefixes.Length];

            for (var index = 0; index < prefixes.Length; index++)
            {
                var prefix = prefixes[index];
                for (int i = 0; i < times; i++)
                {
                    var query = dawg.WithPrefix(prefix);
                    if (max.HasValue)
                    {
                        query = query.Take(max.Value);
                    }
                    results[index] = query.ToHashSet();
                }
            }

            return(results);
        }
 public IEnumerable <string> GetWordsByPrefix(string prefix)
 {
     return(_dawg.WithPrefix(prefix));
 }