Compare commits
No commits in common. "e53d1086cc9d2afd08b34a0be0d11a8dea165b76" and "3077b4d8b8a6b36ec5ac70c0f6b93f0283147460" have entirely different histories.
e53d1086cc
...
3077b4d8b8
@ -3,7 +3,7 @@ namespace Pathfinding;
|
|||||||
public class RPriorityQueue<TKey, TPriority> where TKey : notnull
|
public class RPriorityQueue<TKey, TPriority> where TKey : notnull
|
||||||
{
|
{
|
||||||
public Dictionary<TKey, TPriority> queue;
|
public Dictionary<TKey, TPriority> queue;
|
||||||
public int Count => queue.Count;
|
public int Count { get; private set; }
|
||||||
|
|
||||||
public RPriorityQueue()
|
public RPriorityQueue()
|
||||||
{
|
{
|
||||||
@ -14,12 +14,14 @@ public class RPriorityQueue<TKey, TPriority> where TKey : notnull
|
|||||||
{
|
{
|
||||||
if (!queue.TryAdd(key, priority))
|
if (!queue.TryAdd(key, priority))
|
||||||
queue[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);
|
queue.Remove(retKey);
|
||||||
|
Count = queue.Count;
|
||||||
return retKey;
|
return retKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,6 +30,7 @@ public class RPriorityQueue<TKey, TPriority> where TKey : notnull
|
|||||||
int before = Count;
|
int before = Count;
|
||||||
queue = queue.Where(queueitem => !elements.Contains(queueitem.Key))
|
queue = queue.Where(queueitem => !elements.Contains(queueitem.Key))
|
||||||
.ToDictionary(item => item.Key, item => item.Value);
|
.ToDictionary(item => item.Key, item => item.Value);
|
||||||
|
Count = queue.Count;
|
||||||
return before - Count;
|
return before - Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,6 +38,7 @@ public class RPriorityQueue<TKey, TPriority> where TKey : notnull
|
|||||||
{
|
{
|
||||||
int before = Count;
|
int before = Count;
|
||||||
queue = queue.IntersectBy(exceptKeys, item => item.Key).ToDictionary(item => item.Key, item => item.Value);
|
queue = queue.IntersectBy(exceptKeys, item => item.Key).ToDictionary(item => item.Key, item => item.Value);
|
||||||
|
Count = queue.Count;
|
||||||
return before - Count;
|
return before - Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user