static void Main(string[] args) { List <TestThing> list = new List <TestThing> { new TestThing("", 1), new TestThing("a", 3), new TestThing("a", 5), new TestThing("a", 7), new TestThing("a", 7), new TestThing("", 9), new TestThing("b", 3), new TestThing("b", 5), new TestThing("b", 7), new TestThing("c", 7) }; PriorityQueue.PriorityIsGreater <TestThing> isGreater = (a, b) => a.Value < b.Value; PriorityQueue.PQueue <TestThing> pq = new PriorityQueue.Queue <TestThing>(isGreater, list.ToArray()); TestFunc(pq); pq = new PriorityQueue.StableQueue <TestThing>(isGreater, list.ToArray()); TestFunc(pq); List <int> vals = new List <int> { 1, 5, 2, 3, 5, 4, 3, 2, 4 }; PriorityQueue.PQueue <int> queue = new PriorityQueue.Queue <int>((a, b) => a > b, vals.ToArray()); queue.Remove(7); queue.Remove(3); while (queue.Count > 1) { Console.Write(queue.Pop() + ", "); } Console.WriteLine(queue.Pop()); Console.WriteLine(HR); queue = new PriorityQueue.StableQueue <int>((a, b) => a > b, vals.ToArray()); queue.Remove(7); queue.Remove(3); while (queue.Count > 1) { Console.Write(queue.Pop() + ", "); } Console.WriteLine(queue.Pop()); Console.WriteLine(HR); Console.ReadKey(); }
public ATMPriorityQueue() { this.data = new Queue <T>(); }