Compare commits

..

2 Commits

View File

@ -3,7 +3,7 @@ namespace Pathfinding;
public class RPriorityQueue<TKey, TPriority> where TKey : notnull
{
public Dictionary<TKey, TPriority> queue;
public int Count { get; private set; }
public int Count => queue.Count;
public RPriorityQueue()
{
@ -14,14 +14,12 @@ public class RPriorityQueue<TKey, TPriority> where TKey : notnull
{
if (!queue.TryAdd(key, priority))
queue[key] = priority;
Count = queue.Count;
}
public TKey? Dequeue()
public TKey Dequeue()
{
TKey? retKey = queue.MinBy(item => item.Value).Key;
TKey retKey = queue.MinBy(item => item.Value).Key;
queue.Remove(retKey);
Count = queue.Count;
return retKey;
}
@ -30,7 +28,6 @@ public class RPriorityQueue<TKey, TPriority> where TKey : notnull
int before = Count;
queue = queue.Where(queueitem => !elements.Contains(queueitem.Key))
.ToDictionary(item => item.Key, item => item.Value);
Count = queue.Count;
return before - Count;
}
@ -38,7 +35,6 @@ public class RPriorityQueue<TKey, TPriority> where TKey : notnull
{
int before = Count;
queue = queue.IntersectBy(exceptKeys, item => item.Key).ToDictionary(item => item.Key, item => item.Value);
Count = queue.Count;
return before - Count;
}