|
using System;
using YinYang.CodeProject.Projects.SimplePathfinding.Helpers;
namespace YinYang.CodeProject.Projects.SimplePathfinding.PathFinders.Dijkstra
{
public abstract class BaseDijkstraMap<TNode> : BaseGraphSearchMap<TNode> where TNode : BaseGraphSearchNode<TNode>, IComparable<TNode>
{
#region | Fields |
private readonly PriorityQueue<TNode> priorityQueue;
#endregion
#region | Constructors |
/// <summary>
/// Initializes a new instance of the <see cref="BaseDijkstraMap{TNode}"/> class.
/// </summary>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
protected BaseDijkstraMap(Int32 width, Int32 height) : base(width, height)
{
priorityQueue = new PriorityQueue<TNode>();
}
#endregion
#region << BaseGraphSearchMap >>
/// <summary>
/// See <see cref="BaseGraphSearchMap{TNode}.OnGetCount"/> for more details.
/// </summary>
protected override Int32 OnGetCount()
{
return priorityQueue.Count;
}
/// <summary>
/// See <see cref="BaseGraphSearchMap{TNode}.OnAddNewNode"/> for more details.
/// </summary>
protected override void OnAddNewNode(TNode result)
{
priorityQueue.Enqueue(result);
}
/// <summary>
/// See <see cref="BaseGraphSearchMap{TNode}.OnGetTopNode"/> for more details.
/// </summary>
protected override TNode OnGetTopNode()
{
return priorityQueue.Dequeue();
}
/// <summary>
/// See <see cref="BaseGraphSearchMap{TNode}.OnClear"/> for more details.
/// </summary>
protected override void OnClear()
{
priorityQueue.Clear();
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.