/// <summary> /// Removes all items from the given cell. /// If the items don't occupy another cell, they are removed as well. /// </summary> /// <param name="cell">The cell to remove items from</param> public void Remove(Point cell) { lock (lockObject) { Point c = Clamp(cell); List <T> l; Grid.TryGetValue(c, out l); if (l != null) { foreach (T i in l) { List <Point> pl; ItemDictionary.TryGetValue(i, out pl); if (pl != null) { pl.Remove(c); if (pl.Count == 0) { ListOfPointQueue.Enqueue(pl); ItemDictionary.Remove(i); } } } l.Clear(); ListOfItemQueue.Enqueue(l); Grid.Remove(cell); } } }
/// <summary> /// Removes the given item from the grid. /// </summary> /// <param name="item">The item to remove</param> public void Remove(T item) { lock (lockObject) { List <Point> pl; ItemDictionary.TryGetValue(item, out pl); if (pl == null) { return; } foreach (Point p in pl) { RemoveFromGrid(item, p); } pl.Clear(); ListOfPointQueue.Enqueue(pl); ItemDictionary.Remove(item); } }