예제 #1
0
        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);
        }
예제 #2
0
        public void NonExistentItemCanBeDeleted()
        {
            var tree = new RBush <Point>(maxEntries: 4);

            tree.BulkLoad(points);

            tree.Delete(new Point(13, 13, 13, 13));
        }
예제 #3
0
        public void Delete_TreeIsEmpty_ShouldNotThrow()
        {
            var tree = new RBush <Point>();

            tree.Delete(new Point(1, 1, 1, 1));

            Assert.Equal(0, tree.Count);
        }
예제 #4
0
파일: World.cs 프로젝트: yahyaguzide/daud
 public void BodyRemove(Body body)
 {
     Bodies.Remove(body);
     if (body.IsStatic)
     {
         RTreeStatic.Delete(body);
     }
 }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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,
                },
            });
        }
예제 #10
0
        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());
        }
예제 #11
0
        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));
        }
예제 #12
0
        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());
        }