diff --git a/SpriteCompiler/Adapters/QueueAdapter.cs b/SpriteCompiler/Adapters/QueueAdapter.cs new file mode 100644 index 0000000..d645fde --- /dev/null +++ b/SpriteCompiler/Adapters/QueueAdapter.cs @@ -0,0 +1,42 @@ +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 : IQueue + where T : ISearchNode + where C : IComparable + { + private readonly SimplePriorityQueue queue = new SimplePriorityQueue(); + + public bool Empty { get { return queue.Count == 0; } } + + public void AddRange(IEnumerable items) + { + foreach (var item in items) + { + queue.Enqueue(item, item.PathCost); + } + } + + public void Clear() + { + queue.Clear(); + } + + public void Enqueue(T item) + { + queue.Enqueue(item, item.PathCost); + } + + public T Remove() + { + return queue.Dequeue(); + } + } +}