internal OpResult Remove(T rem, MultidimensionalComparator <T> comparator, int level) { Load(); if (obj == rem) { if (left == null && right == null) { Deallocate(); return(OpResult.TRUNCATE); } else { Modify(); obj = comparator.CloneField(obj, level % comparator.NumberOfDimensions); deleted = true; return(OpResult.OK); } } CompareResult diff = comparator.Compare(rem, obj, level % comparator.NumberOfDimensions); if (diff != CompareResult.GT && left != null) { OpResult result = left.Remove(rem, comparator, level + 1); if (result == OpResult.TRUNCATE) { Modify(); left = null; return(OpResult.OK); } else if (result == OpResult.OK) { return(OpResult.OK); } } if (diff != CompareResult.LT && right != null) { OpResult result = right.Remove(rem, comparator, level + 1); if (result == OpResult.TRUNCATE) { Modify(); right = null; return(OpResult.OK); } else if (result == OpResult.OK) { return(OpResult.OK); } } return(OpResult.NOT_FOUND); }
/// <summary> /// Removes an object from this node or from /// one of its child nodes. /// </summary> internal bool Remove(IIndexable obj) { if (_child0 != null) { if (_child0._boundingBox.ContainsRectangle(obj.BoundingRectangle)) { return(_child0.Remove(obj)); } if (_child1._boundingBox.ContainsRectangle(obj.BoundingRectangle)) { return(_child1.Remove(obj)); } } if (_objects.Contains(obj)) { _objects.Remove(obj); return(true); } return(false); }
/// <summary> /// Removes an object from index. /// </summary> /// <param name="obj">An object to remove</param> /// <returns>true, if the object was removed, false otherwise</returns> public bool Remove <T>(T obj) where T : IIndexable { return(_root.Remove(obj)); }