forked from rettetdemdativ/cs-dijkstra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrioQueue.cs
44 lines (41 loc) · 1.11 KB
/
PrioQueue.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Author(s): Michael Koeppl
using System.Collections.Generic;
namespace dijkstra
{
class PrioQueue : LinkedList<Node>
{
public void AddNodeWithPriority(Node node)
{
if (this.Count == 0)
{
this.AddFirst(node);
}
else
{
if (node.Value >= this.Last.Value.Value)
{
this.AddLast(node);
}
else
{
for (LinkedListNode<Node> it = this.First; it != null; it = it.Next)
{
if (node.Value <= it.Value.Value)
{
this.AddBefore(it, node);
break;
}
}
}
}
}
public bool HasLetter(string letter)
{
for (LinkedListNode<Node> it = this.First; it != null; it = it.Next)
{
if (it.Value.Name == letter) { return true; }
}
return false;
}
}
}