/// <summary> /// Remove all elements located within the given line. /// </summary> /// <param name="Line">A line selecting which elements to remove.</param> public void Remove(ILine1D <T> Line) { #region Initial Checks if (Line == null) { throw new ArgumentNullException("The given line must not be null!"); } #endregion #region Remove embedded data lock (this) { var _List = new List <T>(); foreach (var _Element in EmbeddedData) { if (Line.Contains(_Element)) { _List.Add(_Element); } } foreach (var _Element in _List) { EmbeddedData.Remove(_Element); } } #endregion #region Check subtrees if (Subtree1 != null) { if (Subtree1.Overlaps(Line)) { Subtree1.Remove(Line); } } if (Subtree2 != null) { if (Subtree2.Overlaps(Line)) { Subtree2.Remove(Line); } } #endregion }
/// <summary> /// Return all elements within the given line. /// </summary> /// <param name="Line">A line selecting which elements to return.</param> public IEnumerable <T> Get(ILine1D <T> Line) { #region Initial Checks if (Line == null) { throw new ArgumentNullException("The given line must not be null!"); } #endregion #region Check embedded element foreach (var _Element in EmbeddedData) { if (Line.Contains(_Element)) { yield return(_Element); } } #endregion #region Check subtrees if (Subtree1 != null) { if (Subtree1.Overlaps(Line)) { foreach (var _Element in Subtree1.Get(Line)) { yield return(_Element); } } } if (Subtree2 != null) { if (Subtree2.Overlaps(Line)) { foreach (var _Element in Subtree2.Get(Line)) { yield return(_Element); } } } #endregion }