Skip to content

Commit ac84feb

Browse files
authored
Update README.md
1 parent 6be0959 commit ac84feb

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,19 @@ Priority queue implementations in C#
1818

1919
## Example usage
2020

21-
First define a class that implements `IPriorityElemennt` interface, which will be used in our queue.
21+
First we'll define a sample class that which will be used in our queue.
2222
```cs
23-
class Element : IPriorityElement
23+
class Element
2424
{
2525
public string Name { get; set; }
26-
27-
// required property
2826
public float Priority { get; set; }
2927
}
3028
```
3129

32-
Then we can create a new priority queue using one of the two default implementations
30+
Then we can create a new priority queue using one of the two default implementations, and pass in a comparer
3331
```cs
3432
// Create a new instance of BinaryHeapPriorityQueue
35-
IPriorityQueue<Element> myPriorityQueue = new BinaryHeapPriorityQueue<Element>();
33+
IPriorityQueue<Element> myPriorityQueue = new BinaryHeapPriorityQueue<Element>((a, b) => a.Priority.CompareTo(b.Priority)); // this will produce a min-heap, use b.Priority.CompareTo(b.Priority) for a max-heap
3634
// Insert some elements
3735
myPriorityQueue.Enqueue(new Element { Priority = 5, Name = "A" });
3836
myPriorityQueue.Enqueue(new Element { Priority = 7, Name = "B" });

0 commit comments

Comments
 (0)