2016-11-27 05:40:21 +00:00
|
|
|
|
namespace SpriteCompiler.Adapters
|
|
|
|
|
{
|
|
|
|
|
using Priority_Queue;
|
|
|
|
|
using SpriteCompiler.AI;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
public class QueueAdapter<T, C> : IQueue<T>
|
|
|
|
|
where T : ISearchNode<C>
|
|
|
|
|
where C : IComparable<C>
|
|
|
|
|
{
|
|
|
|
|
private readonly SimplePriorityQueue<T, C> queue = new SimplePriorityQueue<T, C>();
|
|
|
|
|
|
|
|
|
|
public bool Empty { get { return queue.Count == 0; } }
|
|
|
|
|
|
|
|
|
|
public void AddRange(IEnumerable<T> items)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in items)
|
|
|
|
|
{
|
2016-12-05 05:14:51 +00:00
|
|
|
|
Console.WriteLine("Enqueuing " + item + " with cost " + item.EstCost);
|
|
|
|
|
queue.Enqueue(item, item.EstCost);
|
2016-11-27 05:40:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Clear()
|
|
|
|
|
{
|
|
|
|
|
queue.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Enqueue(T item)
|
|
|
|
|
{
|
2016-12-05 05:14:51 +00:00
|
|
|
|
queue.Enqueue(item, item.EstCost);
|
2016-11-27 05:40:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T Remove()
|
|
|
|
|
{
|
|
|
|
|
return queue.Dequeue();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|