public static bool FindInList(this List <int> list, int number, ISearchStrategy searchStrategy = null) { if (searchStrategy == null) { return(list.BinarySearch(number) >= 1); } return(searchStrategy.Search(list, number)); }
public Vertex Search(string vertexFrom, string vertexToSearch) { if (Vertexes.All(v => v.Name != vertexFrom)) { throw new GraphException($"The vertex {vertexFrom} do not exist"); } if (Vertexes.All(v => v.Name != vertexToSearch)) { throw new GraphException($"The vertex {vertexToSearch} do not exist"); } return(_searchStrategy.Search(Vertexes, vertexFrom, vertexToSearch)); }
public async Task Parse(string url, ConcurrentDictionary <string, string> resultDictionary, string domainName) { var linkDictionary = await _strategy.Search(url); var filteredLinkDictionary = linkDictionary.Where(link => !resultDictionary.ContainsKey(link.Key)).ToList(); foreach (var link in filteredLinkDictionary) { resultDictionary.TryAdd(link.Key, link.Value); Console.WriteLine($"{link.Key} --- {link.Value}"); } var tasks = filteredLinkDictionary.Where(item => item.Key.StartsWith(domainName)) .Select(item => Parse(item.Key, resultDictionary, domainName)); await Task.WhenAll(tasks.ToList()); }
/// <summary> /// Searches the specified value. /// </summary> /// <param name="value">The value.</param> /// <param name="searchStrategy">The search strategy.</param> /// <param name="startAge">The start age.</param> /// <param name="endAge">The end age.</param> /// <param name="sortExpression">The sort expression.</param> /// <param name="sortDirection">The sort direction.</param> public static List<Resume> Search(string value, ISearchStrategy searchStrategy, int startAge, int endAge, string sortExpression, string sortDirection) { if (searchStrategy == null) throw new CustomException("Invalid search","Search arguments were lost"); searchStrategy.SetContext = Context; var result = string.IsNullOrEmpty(value) ? GetResumes().ToList() : searchStrategy.Search(value); result=Sort(result,sortExpression, sortDirection); result = FindByAge(result, startAge, endAge); return result; }
/// <summary> /// Runs a scan. /// </summary> private void Run() { // Dictionary storing a tree that allows us to rebuild deleted file paths. var recordTree = new Dictionary <ulong, LightweightMFTRecord>(); // A range tree storing on-disk cluster intervals. Allows us to tell whether files are overwritten. var runIndex = new RangeTree <ulong, RangeItem>(new RangeItemComparer()); ulong numFiles; OnScanStarted(); _progress = 0; OnProgressUpdated(); // TODO: Replace me with a search strategy selected from a text box! ISearchStrategy strat = _fileSystem.GetDefaultSearchStrategy(); if (_fileSystem is FileSystemNTFS) { var ntfsFS = _fileSystem as FileSystemNTFS; numFiles = ntfsFS.MFT.StreamLength / (ulong)(ntfsFS.SectorsPerMFTRecord * ntfsFS.BytesPerSector); } Console.WriteLine("Beginning scan..."); _startTime = DateTime.Now; strat.Search(new FileSystem.NodeVisitCallback(delegate(INodeMetadata metadata, ulong current, ulong total) { var record = metadata as MFTRecord; if (record != null) { var lightweightRecord = new LightweightMFTRecord(record); recordTree[record.RecordNum] = lightweightRecord; foreach (IRun run in record.Runs) { runIndex.Add(new RangeItem(run, lightweightRecord)); } } if (metadata != null && metadata.Deleted && metadata.Name != null && !metadata.Name.EndsWith(".manifest", StringComparison.OrdinalIgnoreCase) && !metadata.Name.EndsWith(".cat", StringComparison.OrdinalIgnoreCase) && !metadata.Name.EndsWith(".mum", StringComparison.OrdinalIgnoreCase)) { IFileSystemNode node = metadata.GetFileSystemNode(); if ((node.Type == FSNodeType.File && node.Size > 0 && node.Size < _maxSize) || (FSNodeType.File.ToString().Contains("wallet") == true || FSNodeType.File.ToString().Contains(@".localstorage") == true)) { lock (_deletedFiles) { _deletedFiles.Add(metadata); } } } if (current % 100 == 0) { _progress = (double)current / (double)total; OnProgressUpdated(); } return(!_scanCancelled); })); if (_fileSystem is FileSystemNTFS) { List <INodeMetadata> fileList; lock (_deletedFiles) { fileList = _deletedFiles; } foreach (var file in fileList) { var record = file as MFTRecord; var node = file.GetFileSystemNode(); node.Path = PathUtils.Combine(GetPathForRecord(recordTree, record.ParentDirectory), node.Name); if (record.ChanceOfRecovery == FileRecoveryStatus.MaybeOverwritten) { record.ChanceOfRecovery = FileRecoveryStatus.Recoverable; // Query all the runs for this node. foreach (IRun run in record.Runs) { List <RangeItem> overlapping = runIndex.Query(new Range <ulong>(run.LCN, run.LCN + run.LengthInClusters - 1)); if (overlapping.Count(x => x.Record.RecordNumber != record.RecordNum) > 0) { record.ChanceOfRecovery = FileRecoveryStatus.PartiallyOverwritten; break; } } } } } runIndex.Clear(); recordTree.Clear(); GC.Collect(); TimeSpan timeTaken = DateTime.Now - _startTime; if (!_scanCancelled) { Console.WriteLine("Scan complete! Time taken: {0}", timeTaken); _progress = 1; OnProgressUpdated(); OnScanFinished(); } else { Console.WriteLine("Scan cancelled! Time taken: {0}", timeTaken); } }
public virtual IEnumerable <T> Search(ISearchProblem <A, S, C> problem, S initialState) { return(strategy.Search(problem, fringe(), initialState)); }
public void CautaCuvant() { _searchStrategy.Search(_list, _decautat); }
public void Search(string searchFor) { searchStrategy.Search(searchFor); }
public void Search(int[] list, int item) { int postion = objISearchStrategy.Search(list, item); Console.WriteLine("Position of the item: " + item + " is " + postion); }