// MIT License - Copyright (c) 2024 wallstop
// Full license text: https://github.com/wallstop/unity-helpers/blob/main/LICENSE
namespace WallstopStudios.UnityHelpers.Core.DataStructure
{
using System.Collections.Generic;
using UnityEngine;
///
/// Contract for 2D spatial trees (quad trees, k-d trees, etc.) that support range and nearest-neighbor queries.
/// Enables algorithms to consume spatial containers without caring about the concrete backing structure.
///
///
/// tree = new QuadTree2D(worldBounds);
/// List results = new List();
/// tree.GetElementsInRange(playerPosition, 5f, results);
/// ]]>
///
///
/// Result buffers: Each query clears the provided before appending new entries. Reuse the same list between calls to avoid repeated allocations.
///
public interface ISpatialTree2D
{
Bounds Boundary { get; }
List GetElementsInRange(
Vector2 position,
float range,
List elementsInRange,
float minimumRange = 0f
);
List GetElementsInBounds(Bounds bounds, List elementsInBounds);
List GetApproximateNearestNeighbors(
Vector2 position,
int count,
List nearestNeighbors
);
}
}