Priority Queues with C#: Listing 2.

The Employee class.

public class Employee : IComparable <Employee >
  public string lastName;
  public double priority; // Smaller values are higher priority

  public Employee(string lastName, double priority)
    this.lastName = lastName;
    this.priority = priority;

  public override string ToString()
    return "(" + lastName + ", " + priority.ToString("F1") + ")";

  public int CompareTo(Employee other)
    if (this.priority  < other.priority) return -1;
    else if (this.priority  > other.priority) return 1;
    else return 0;

About the Author

Dr. James McCaffrey works for Microsoft Research in Redmond, Wash. He has worked on several Microsoft products including Azure and Bing. James can be reached at [email protected].

comments powered by Disqus


  • Java on Visual Studio Code Going Cloud Native

    Cloud-native development figures prominently in a new roadmap published by Microsoft's Java on Visual Studio Code dev team.

  • Speed Lines Graphic

    Quantum-Inspired Annealing Using C# or Python

    Dr. James McCaffrey of Microsoft Research explains a new idea that slightly modifies standard simulated annealing by borrowing ideas from quantum mechanics.

  • Visual Studio 2022 v17.1 Preview 3 Improves Web Tools

    Microsoft quietly shipped Visual Studio 2022 v17.1 Preview 3 with enhancements to web tools.

  • Progress Telerik Adds 20-Plus Components for Blazor, .NET MAUI and WinUI

    The R1 2022 release of Progress Telerik development tooling adds more than 20 new components to the Blazor, .NET MAUI and WinUI offerings.

Upcoming Events