public WorksheetMatch GetMathcesInWorksheet(Worksheet ws, Regex rgx) { var cells = ws.FindCells(rgx); if (cells != null && cells.Count() > 0) { var worksheetMatch = new WorksheetMatch() { SheetName = ws.GetName() }; foreach (var cell in cells) { var cellMatch = new CellMatch() { CellAddress = cell.CellReference?.Value, Value = cell.GetValue() }; worksheetMatch.CellMatches.Add(cellMatch); } return(worksheetMatch); } return(null); }
public IEnumerable <MapCell> FloodFill(MapCell start, CellMatch match) { HashSet <MapCell> done = new HashSet <MapCell>(); Queue <MapCell> todo = new Queue <MapCell>(); todo.Enqueue(start); while (todo.Count > 0) { MapCell target = todo.Dequeue(); yield return(target); foreach (MapCell neighbor in target.neighbors) { if (!done.Contains(neighbor) && match(target, neighbor)) { todo.Enqueue(neighbor); } } done.Add(target); } }