//using System.Collections.Generic;
namespace WinFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
PriorityQueue<string, int> queue = new PriorityQueue<string, int>();
queue.Enqueue("Item A", 34);
queue.Enqueue("Item B", 98);
queue.Enqueue("Item C", 5);
queue.Enqueue("Item D", 9);
label1.Text = "";
while (queue.TryDequeue(out string item, out int priority)) {
label1.Text += item + " " + priority + Environment.NewLine;
}
}
}
}
/*
* run:
*
* Item C 5
* Item D 9
* Item A 34
* Item B 98
*
*/