diff --git a/Quadtree/Quadtree.cs b/Quadtree/Quadtree.cs
index 89e1826..6228ab2 100644
--- a/Quadtree/Quadtree.cs
+++ b/Quadtree/Quadtree.cs
@@ -12,60 +12,48 @@ namespace SpatialCollections
/// Type of the managed entities.
// TODO: Support for moving entites without having to remove and re-add them.
// TODO: Add method to prune empty leaves. An empty leaf is not removed automatically when its last entity is removed.
- public class Quadtree
+ public class Quadtree(int maxLeafSize, int maxTreeDepth, Func getPositionCallback)
{
// TODO: It should be possible to calculate whether average query time will be better with or without split, without resorting to max leaf size and max tree depth.
///
/// Maximum number of items in a leaf vertex before it is split, unless the depth of the leaf is greater or
/// equal to the maximum tree depth.
///
- private readonly int _maxLeafSize;
+ private readonly int _maxLeafSize = maxLeafSize;
///
/// Maximum depth of the quadtree, that is the maximum allowed length of the path from the root to a new leaf
/// when determining whether a leaf vertex may be split.
///
- private readonly int _maxTreeDepth;
+ private readonly int _maxTreeDepth = maxTreeDepth;
///
/// Callback to determine the position of an entity.
///
- private readonly Func _getPositionCallback;
+ private readonly Func _getPositionCallback = getPositionCallback;
///
/// The list of quadtree vertices. The root vertex is always the first item. The four child vertices of a branch
/// are always created together and stored contiguously.
///
- private readonly List _vertices;
+ private readonly List _vertices = [new(-1, 0)];
///
/// The list of all items stored in the quadtree.
///
- private readonly List> _items;
+ private readonly List> _items = [];
- private Rectangle _rootBoundingBox;
+ private Rectangle _rootBoundingBox = new(Vector2.Zero, Vector2.Zero);
///
/// Stack of vertex indices with their bounding boxes. It is reused for each query.
///
- private readonly Stack _queryStack;
+ private readonly Stack _queryStack = new();
///
/// Stack of vertex indices. It is reused for each query.
///
- private readonly Stack _vertexStack;
-
- public Quadtree(int maxLeafSize, int maxTreeDepth, Func getPositionCallback)
- {
- _maxLeafSize = maxLeafSize;
- _maxTreeDepth = maxTreeDepth;
- _getPositionCallback = getPositionCallback;
- _vertices = [new(-1, 0)];
- _items = [];
- _rootBoundingBox = new Rectangle(Vector2.Zero, Vector2.Zero);
- _queryStack = new Stack();
- _vertexStack = new Stack();
- }
+ private readonly Stack _vertexStack = new();
public int Count => _items.Count;