Exemple #1
0
        private IEnumerable<string> Search(SuffixTreeNode node, SearchOptions options)
        {
            if (options.Keyword.Length == 0)
                return node.Values;

            var c = options.Keyword.First();
            if (options.CaseSensitive == false) {
                SuffixTreeNode nextUpperNode;
                SuffixTreeNode nextLowerNode;
                node.Nodes.TryGetValue(char.ToLower(c), out nextLowerNode);
                node.Nodes.TryGetValue (char.ToUpper (c), out nextUpperNode);
                if (nextUpperNode == null && nextLowerNode == null) return Enumerable.Empty<string>();

                options.Keyword = options.Keyword.Substring(1);

                if (nextUpperNode != null && nextLowerNode != null)
                    return Search(nextLowerNode, options.Clone()).Union(Search(nextUpperNode, options.Clone()));

                return Search(nextLowerNode ?? nextUpperNode, options.Clone());

            } else {
                SuffixTreeNode nextNode;
                node.Nodes.TryGetValue(c, out nextNode);
                if (nextNode == null) return Enumerable.Empty<string>();

                options.Keyword = options.Keyword.Substring(1);
                return Search(nextNode, options);
            }
        }
Exemple #2
0
 public IEnumerable<string> Search(SearchOptions options)
 {
     return Search(RootNode, options);
 }
        public IEnumerable<string> Search(SearchOptions searchOptions)
        {
            var result = _flatNames.Search(searchOptions);

            return result.Where(path => IsInFolder(searchOptions.RestrictToFolder ?? "", path.TrimEnd('/'), searchOptions.RecursionDistance));
        }
        public IList<string> Search(string keyword, string folder, bool recursive, bool caseSensitive)
        {
            var searchOptions = new SearchOptions
                {
                    Keyword = keyword,
                    CaseSensitive = caseSensitive,
                    RecursionDistance = (recursive ? -1 : 0),
                    RestrictToFolder = folder == "/" ? "" : folder
                };

            return _searchService.Search(searchOptions).ToList();
        }
 public IEnumerable<string> Search(SearchOptions searchOptions)
 {
     return _indexService.Search(searchOptions).Where(_manipulator.Exists);
 }