Simplify collection initialization

This commit is contained in:
Stefan Müller 2025-09-27 23:32:48 +02:00
parent 09ac8d0433
commit f6e5a34278
2 changed files with 3 additions and 3 deletions

View File

@ -60,8 +60,8 @@ namespace SpatialCollections
_maxLeafSize = maxLeafSize; _maxLeafSize = maxLeafSize;
_maxTreeDepth = maxTreeDepth; _maxTreeDepth = maxTreeDepth;
_getPositionCallback = getPositionCallback; _getPositionCallback = getPositionCallback;
_vertices = new List<QuadtreeVertex>() { new(-1, 0) }; _vertices = [new(-1, 0)];
_items = new List<QuadtreeItem<T>>(); _items = [];
_rootBoundingBox = new Rectangle(Vector2.Zero, Vector2.Zero); _rootBoundingBox = new Rectangle(Vector2.Zero, Vector2.Zero);
_queryStack = new Stack<QuadtreeQuery>(); _queryStack = new Stack<QuadtreeQuery>();
_vertexStack = new Stack<int>(); _vertexStack = new Stack<int>();

View File

@ -43,7 +43,7 @@ namespace QuadtreeTests
public void TestQuery() public void TestQuery()
{ {
AddEntitiesAndAssertCount(); AddEntitiesAndAssertCount();
List<TestEntity> result = new(); List<TestEntity> result = [];
_quadtree.Query(new Rectangle(new Vector2(2.5f, 2.5f), new Vector2(10.0f, 10.0f)), result); _quadtree.Query(new Rectangle(new Vector2(2.5f, 2.5f), new Vector2(10.0f, 10.0f)), result);
Assert.That(result, Has.Count.EqualTo(2)); Assert.That(result, Has.Count.EqualTo(2));
} }