using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Diagnostics; using System.Collections.Generic; namespace Project2 { struct Pair { public int key; public double value; } class PriorityQueue { private SortedList PseudoQueue; private double value; private int key; public int Key { get { return key; } } public double Value { get { return value; } } public bool Empty { get { return PseudoQueue.Count == 0; } } public PriorityQueue() { PseudoQueue = new SortedList(); } public void push(int key, double Value) { PseudoQueue.Add(key, Value); } public void pop() { key = PseudoQueue.Keys.ElementAt(0); value = PseudoQueue[key]; PseudoQueue.Remove(key); } public int GetCount() { return PseudoQueue.Count; } } class Program { static void Main(string[] args) { PriorityQueue prior = new PriorityQueue(); prior.push(1, 2.0); prior.push(10, 3.0); prior.push(41, 4.0); prior.push(12, 5.0); prior.pop(); Console.WriteLine("key->{0} value->{1}", prior.Key,prior.Value); prior.pop(); Console.WriteLine("key->{0} velue->{1}", prior.Key, prior.Value); prior.pop(); Console.WriteLine("key->{0} velue->{1}", prior.Key, prior.Value); prior.pop(); Console.WriteLine("key->{0} velue->{1}", prior.Key, prior.Value); Console.ReadKey(); } } }