public void Remove(Aabb <Vec2> rect, T value) { var xival = _tree.Find(rect.Left, rect.Right); if (xival == null) { throw new KeyNotFoundException("Given rectangle not found in the tree"); } var yival = xival.Data.Find(rect.Bottom, rect.Top); if (yival == null) { throw new KeyNotFoundException("Given rectangle not found in the tree"); } var newData = yival.Data.Remove(value); if (yival.Data == newData) { throw new KeyNotFoundException("Given value was not found"); } yival.Data = newData; _count--; if (newData != null) { return; } if (xival.Data.Count > 1) { xival.Data.Remove(yival); } else { _tree.Remove(xival); } }
public void Remove(Aabb <Vec3> box, T value) { var xival = _tree.Find(box.Left, box.Right); if (xival == null) { throw new KeyNotFoundException("Given box not found in the tree"); } var yival = xival.Data.Find(box.Bottom, box.Top); if (yival == null) { throw new KeyNotFoundException("Given box not found in the tree"); } var zival = yival.Data.Find(box.Back, box.Front); if (zival == null) { throw new KeyNotFoundException("Given box not found in the tree"); } var newData = zival.Data.Remove(value); if (newData == zival.Data) { throw new KeyNotFoundException("Given value was not found"); } zival.Data = newData; _count--; if (newData != null) { return; } if (xival.Data.Count > 1) { if (yival.Data.Count > 1) { yival.Data.Remove(zival); } else { xival.Data.Remove(yival); } } else { _tree.Remove(xival); } }