mirror of
https://github.com/lscharen/iigs-sprite-compiler.git
synced 2024-12-07 15:49:39 +00:00
Adaptor around the Fast Priority Queue NuGet package
This commit is contained in:
parent
77f92507b7
commit
1a575a91b6
42
SpriteCompiler/Adapters/QueueAdapter.cs
Normal file
42
SpriteCompiler/Adapters/QueueAdapter.cs
Normal file
@ -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<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)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user