public static bool KeysSetEquals( this ImmutableHashSet <IKey> validKeys, ImmutableArray <Key> keyboardState) { var validKeysList = validKeys.ToList(); return(validKeysList.Count == keyboardState.Length && Enumerable.All(keyboardState, key => validKeysList.PickFirstOrDefault(x => x.IsIncluded(key)) != null)); }
private Tuple<IEnumerable<Cell>, int> GetPointsFromClearing(ImmutableHashSet<Cell> allCells) { IEnumerable<Cell> newCells = allCells.ToList(); int addPoints = 0; foreach (int row in allCells.Select(c => c.Y).Distinct(). Where(row => CheckRowFull(allCells, row))) { int rowNumber = row; newCells = newCells.Where(c => c.Y != rowNumber).ToList(); var shiftCells = newCells.Where(r => r.Y < rowNumber).Select(c => new Cell(c.X, c.Y+1)).ToList(); newCells = newCells.Where(r => r.Y > rowNumber).Union(shiftCells); addPoints++; } return new Tuple<IEnumerable<Cell>, int>(newCells, addPoints); }