public void DeleteAndSearchTest() { var tree = new RBush <Point>(maxEntries: 4); tree.BulkLoad(points); var len = points.Length; // Delete an existent point. bool resultExistent = tree.Delete(points[0]); var shouldFindPointsExistent = points .Skip(1) .OrderBy(x => x) .ToList(); var foundPointsExistent = tree.Search() .OrderBy(x => x) .ToList(); // Try to delete a non-existent point. bool resultNonExistent = tree.Delete(new Point(1245, 1233, 1245, 1233)); var shouldFindPointsNonExistent = shouldFindPointsExistent; var foundPointsNonExistent = tree.Search() .OrderBy(x => x) .ToList(); Assert.True(resultExistent); Assert.Equal(shouldFindPointsExistent, foundPointsExistent); Assert.False(resultNonExistent); Assert.Equal(shouldFindPointsNonExistent, foundPointsNonExistent); }
public void NonExistentItemCanBeDeleted() { var tree = new RBush <Point>(maxEntries: 4); tree.BulkLoad(points); tree.Delete(new Point(13, 13, 13, 13)); }
public void Delete_TreeIsEmpty_ShouldNotThrow() { var tree = new RBush <Point>(); tree.Delete(new Point(1, 1, 1, 1)); Assert.Equal(0, tree.Count); }
public void BodyRemove(Body body) { Bodies.Remove(body); if (body.IsStatic) { RTreeStatic.Delete(body); } }
public void NonExistentItemCanBeDeleted() { var tree = new RBush <Point>(maxEntries: 4); tree.BulkLoad(points); tree.Delete(new Point(13, 13, 13, 13)); Assert.Equal(points.Length, tree.Count); }
public void Delete_DeletingLastPoint_ShouldNotThrow() { var tree = new RBush <Point>(); Point p = new Point(1, 1, 1, 1); tree.Insert(p); tree.Delete(p); Assert.Equal(0, tree.Count); }
public void BasicRemoveTest() { var tree = new RBush <Point>(maxEntries: 4); tree.BulkLoad(points); var len = points.Length; tree.Delete(points[0]); tree.Delete(points[1]); tree.Delete(points[2]); tree.Delete(points[len - 1]); tree.Delete(points[len - 2]); tree.Delete(points[len - 3]); var shouldFindPoints = points .Skip(3).Take(len - 6) .OrderBy(x => x) .ToList(); var foundPoints = tree.Search() .OrderBy(x => x) .ToList(); Assert.Equal(shouldFindPoints, foundPoints); Assert.Equal(shouldFindPoints.Count, tree.Count); Assert.Equal( shouldFindPoints.Aggregate(Envelope.EmptyBounds, (e, p) => e.Extend(p.Envelope)), tree.Envelope); }
public void BasicRemoveTest() { var tree = new RBush <Point>(maxEntries: 4); tree.BulkLoad(points); var len = points.Length; tree.Delete(points[0]); tree.Delete(points[1]); tree.Delete(points[2]); tree.Delete(points[len - 1]); tree.Delete(points[len - 2]); tree.Delete(points[len - 3]); var shouldFindPoints = points .Skip(3).Take(len - 6) .OrderBy(x => x) .ToList(); var foundPoints = tree.Search() .OrderBy(x => x) .ToList(); Assert.Equal(shouldFindPoints, foundPoints); }
public void NonExistentItemCanBeDeleted() { var tree = new RBush <Point>(maxEntries: 4); tree.BulkLoad(points); tree.Delete(new Point { Envelope = new Envelope { MinX = 13, MinY = 13, MaxX = 13, MaxY = 13, }, }); }
public void BulkLoadAfterDeleteTest2() { var pts = GetPoints(20); var ptsDelete = pts.Take(4); var tree = new RBush <Point>(maxEntries: 4); tree.BulkLoad(pts); foreach (var item in ptsDelete) { tree.Delete(item); } tree.BulkLoad(ptsDelete); Assert.Equal(pts.Count, tree.Search().Count); Assert.Equal(pts.OrderBy(x => x).ToList(), tree.Search().OrderBy(x => x).ToList()); }
public void AdditionalRemoveTest() { var tree = new RBush <Point>(); var numDelete = 18; foreach (var p in points) { tree.Insert(p); } foreach (var p in points.Take(numDelete)) { tree.Delete(p); } Assert.Equal(points.Length - numDelete, tree.Count); Assert.Equal(points.Skip(numDelete).OrderBy(x => x), tree.Search().OrderBy(x => x)); }
public void InsertAfterDeleteTest1() { var pts = GetPoints(20); var ptsDelete = pts.Take(18); var tree = new RBush <Point>(maxEntries: 4); foreach (var item in pts) { tree.Insert(item); } foreach (var item in ptsDelete) { tree.Delete(item); } foreach (var item in ptsDelete) { tree.Insert(item); } Assert.Equal(pts.Count, tree.Search().Count); Assert.Equal(pts.OrderBy(x => x).ToList(), tree.Search().OrderBy(x => x).ToList()); }