当前位置: 首页>>代码示例>>C#>>正文


C# QuadTree.Remove方法代码示例

本文整理汇总了C#中QuadTree.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# QuadTree.Remove方法的具体用法?C# QuadTree.Remove怎么用?C# QuadTree.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QuadTree的用法示例。


在下文中一共展示了QuadTree.Remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestUnindexedItemRemoval

    public void TestUnindexedItemRemoval() {
      QuadTree<TestItem> quadTree = new QuadTree<TestItem>(
        new BoundingRectangle(-100.0f, -100.0f, 100.0f, 100.0f)
      );
      quadTree.MaxItemsPerNode = 32;

      Assert.IsFalse(
        quadTree.Remove(new TestItem(new BoundingRectangle()))
      );
    }
开发者ID:pr0gramm3r1,项目名称:AngryTanks,代码行数:10,代码来源:QuadTree.Test.cs

示例2: QuadTreeTestTwo

        public void QuadTreeTestTwo()
        {
            int numPoints = 1000;
            double BoundarySize = 1000;
            int seed = 0;
            Random RandGen = new Random(seed);

            QuadTree<int> Tree = new QuadTree<int>(new GridRectangle(-BoundarySize, BoundarySize, -BoundarySize, BoundarySize));

            GridVector2[] points = new GridVector2[numPoints];

            //Create the QuadTree
            for (int i = 0; i < numPoints; i++)
            {
                points[i] = new GridVector2(RandGen.NextDouble() * BoundarySize, RandGen.NextDouble() * BoundarySize);
                Tree.Add(points[i], i);
            }

            double distance;

            //Check to see we can find every item in the quad tree
            for (int i = 0; i < numPoints; i++)
            {

                int iFound = Tree.FindNearest(points[i], out distance);
                Debug.Assert(iFound == i, "Could not find previously inserted point");
            }

            //Remove half the points
            for (int i = 0; i < numPoints / 2; i++)
            {
                Tree.Remove(i);

                //Make sure if we look for the removed point we get an index higher than the ones we've already removed
                int iFound = Tree.FindNearest(points[i], out distance);
                Debug.Assert(iFound > i, "Found previously deleted point");
            }

            //Look for the remaining points
            for (int i = numPoints / 2; i < numPoints; i++)
            {
                //Make sure if we look for the removed point we get an index higher than the ones we've already removed
                int iFound = Tree.FindNearest(points[i], out distance);
                Debug.Assert(iFound == i, "Could not find previously inserted point after deletes");
            }

            //Re-insert the removed points
            for (int i = 0; i < numPoints / 2; i++)
            {
                Tree.Add(points[i], i);

                //Make sure if we look for the removed point we get an index higher than the ones we've already removed
                int iFound = Tree.FindNearest(points[i], out distance);
                Debug.Assert(iFound == i, "Could not find newly inserted point after deletes");
            }

            //Look for the remaining points
            for (int i = numPoints / 2; i < numPoints; i++)
            {
                //Make sure if we look for the removed point we get an index higher than the ones we've already removed
                int iFound = Tree.FindNearest(points[i], out distance);
                Debug.Assert(iFound == i, "Could not find previously inserted point after delete and insert");
            }

            //Delete all the points
            for (int i = 0; i < numPoints; i++)
            {
                Tree.Remove(i);

                //Make sure if we look for the removed point we get an index higher than the ones we've already removed
                if (i < numPoints - 1)
                {
                    int iFound = Tree.FindNearest(points[i], out distance);
                    Debug.Assert(iFound > i, "Found previously deleted point");
                }
            }

            //Insert some points into the empty tree to make sure we still can
            for (int i = 0; i < numPoints; i++)
            {
                points[i] = new GridVector2(RandGen.NextDouble() * BoundarySize, RandGen.NextDouble() * BoundarySize);
                Tree.Add(points[i], i);
            }

            //Check to see we can find every item in the quad tree
            for (int i = 0; i < numPoints; i++)
            {

                int iFound = Tree.FindNearest(points[i], out distance);
                Debug.Assert(iFound == i, "Could not find previously inserted point");
            }

            //The end
        }
开发者ID:abordt,项目名称:Viking,代码行数:94,代码来源:QuadTreeTest.cs


注:本文中的QuadTree.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。