Exemple #1
0
        public void TestAddSameIndividual()
        {
            QuadTreeRectF<QTreeObject> qtree = new QuadTreeRectF<QTreeObject>();
            List<QTreeObject> list = new List<QTreeObject>();
            for (int i = 0; i < 10000; i++)
            {
                qtree.Add(new QTreeObject(new RectangleF(1, 1, 1, 1)));
            }

            var result = qtree.GetObjects(new RectangleF(-100, -100, 200, 200));
            Assert.AreEqual(result.Distinct().Count(), result.Count);
            Assert.AreEqual(10000, result.Count);
        }
Exemple #2
0
        public void TestListGetAll()
        {
            QuadTreeRectF <QTreeObject> qtree = new QuadTreeRectF <QTreeObject>();

            qtree.AddRange(new List <QTreeObject>
            {
                new QTreeObject(new RectangleF(10, 10, 10, 10)),
                new QTreeObject(new RectangleF(-1000, 1000, 10, 10))
            });

            var list = qtree.GetAllObjects();

            Assert.AreEqual(2, list.Count());
        }
Exemple #3
0
        public void TestListQueryEnum()
        {
            QuadTreeRectF <QTreeObject> qtree = new QuadTreeRectF <QTreeObject>();

            qtree.AddRange(new List <QTreeObject>
            {
                new QTreeObject(new RectangleF(10, 10, 10, 10)),
                new QTreeObject(new RectangleF(-1000, 1000, 10, 10))
            });

            var list = qtree.EnumObjects(new RectangleF(9, 9, 20, 20));

            Assert.AreEqual(1, list.Count());
        }
Exemple #4
0
        public void TestAddMany()
        {
            Random r = new Random(1000);
            QuadTreeRectF<QTreeObject> qtree = new QuadTreeRectF<QTreeObject>();
            for (int i = 0; i < 10000; i++)
            {
                qtree.Add(new QTreeObject(new RectangleF(r.Next(0, 1000) / 1000f, r.Next(0, 1000) / 1000f, r.Next(1000, 20000) / 1000f, r.Next(1000, 20000) / 1000f)));
            }

            var result = qtree.GetObjects(new RectangleF(-100, -100, 200, 200));
            Assert.AreEqual(result.Distinct().Count(), result.Count);

            result = qtree.GetObjects(new RectangleF(-.100f, -.100f, .200f, .200f));
            Assert.AreEqual(result.Distinct().Count(), result.Count);
        }
Exemple #5
0
        public void TestAddSameIndividual()
        {
            QuadTreeRectF <QTreeObject> qtree = new QuadTreeRectF <QTreeObject>();
            List <QTreeObject>          list  = new List <QTreeObject>();

            for (int i = 0; i < 10000; i++)
            {
                qtree.Add(new QTreeObject(new RectangleF(1, 1, 1, 1)));
            }

            var result = qtree.GetObjects(new RectangleF(-100, -100, 200, 200));

            Assert.AreEqual(result.Distinct().Count(), result.Count);
            Assert.AreEqual(10000, result.Count);
        }
Exemple #6
0
        public void TestAddMany()
        {
            Random r = new Random(1000);
            QuadTreeRectF <QTreeObject> qtree = new QuadTreeRectF <QTreeObject>();

            for (int i = 0; i < 10000; i++)
            {
                qtree.Add(new QTreeObject(new RectangleF(r.Next(0, 1000) / 1000f, r.Next(0, 1000) / 1000f, r.Next(1000, 20000) / 1000f, r.Next(1000, 20000) / 1000f)));
            }

            var result = qtree.GetObjects(new RectangleF(-100, -100, 200, 200));

            Assert.AreEqual(result.Distinct().Count(), result.Count);

            result = qtree.GetObjects(new RectangleF(-.100f, -.100f, .200f, .200f));
            Assert.AreEqual(result.Distinct().Count(), result.Count);
        }
Exemple #7
0
        public void TestListQueryOutput()
        {
            QuadTreeRectF<QTreeObject> qtree = new QuadTreeRectF<QTreeObject>();
            qtree.AddRange(new List<QTreeObject>
            {
                new QTreeObject(new RectangleF(10,10,10,10)),
                new QTreeObject(new RectangleF(-1000,1000,10,10))
            });

            var list = new List<QTreeObject>();
            qtree.GetObjects(new RectangleF(9, 9, 20, 20), list);
            Assert.AreEqual(1, list.Count);
        }
Exemple #8
0
        public void TestListGetAll()
        {
            QuadTreeRectF<QTreeObject> qtree = new QuadTreeRectF<QTreeObject>();
            qtree.AddRange(new List<QTreeObject>
            {
                new QTreeObject(new RectangleF(10,10,10,10)),
                new QTreeObject(new RectangleF(-1000,1000,10,10))
            });

            var list = qtree.GetAllObjects();
            Assert.AreEqual(2, list.Count());
        }