namespace RobotNet.RobotManager.Services.Planner;

public class PriorityQueue<T>(Comparison<T> comparison)
{
    public List<T> Items => items;
    private readonly List<T> items = [];

    public void Enqueue(T item)
    {
        items.Add(item);
        items.Sort(comparison);
    }

    public T Dequeue()
    {
        if (items.Count == 0) throw new InvalidOperationException("Queue is empty");
        var item = items[0];
        items.RemoveAt(0);
        return item;
    }

    public int Count => items.Count;
}
