public void Add(Int32 row, Int32 column, XLCell cell) { Count++; IncrementUsage(RowsUsed, row); IncrementUsage(ColumnsUsed, column); if (!RowsCollection.TryGetValue(row, out Dictionary <int, XLCell> columnsCollection)) { columnsCollection = new Dictionary <int, XLCell>(); RowsCollection.Add(row, columnsCollection); } columnsCollection.Add(column, cell); if (row > MaxRowUsed) { MaxRowUsed = row; } if (column > MaxColumnUsed) { MaxColumnUsed = column; } if (Deleted.TryGetValue(row, out HashSet <int> delHash)) { delHash.Remove(column); } }
public void Remove(Int32 row, Int32 column) { Count--; var rowRemoved = DecrementUsage(RowsUsed, row); var columnRemoved = DecrementUsage(ColumnsUsed, column); if (rowRemoved && row == MaxRowUsed) { MaxRowUsed = RowsUsed.Keys.Any() ? RowsUsed.Keys.Max() : 0; } if (columnRemoved && column == MaxColumnUsed) { MaxColumnUsed = ColumnsUsed.Keys.Any() ? ColumnsUsed.Keys.Max() : 0; } if (Deleted.TryGetValue(row, out HashSet <Int32> delHash)) { if (!delHash.Contains(column)) { delHash.Add(column); } } else { delHash = new HashSet <int>(); delHash.Add(column); Deleted.Add(row, delHash); } if (RowsCollection.TryGetValue(row, out Dictionary <Int32, XLCell> columnsCollection)) { columnsCollection.Remove(column); if (columnsCollection.Count == 0) { RowsCollection.Remove(row); } } }