@@ -14,11 +14,9 @@ Usage:
14
14
``` julia
15
15
PriorityQueue {K, V} () # construct a new priority queue with keys of type K and priorities of type V (forward ordering by default)
16
16
PriorityQueue {K, V} (ord) # construct a new priority queue with the given types and ordering ord (Base.Order.Forward or Base.Order.Reverse)
17
- enqueue! (pq, k, v) # insert the key k into pq with priority v
18
- enqueue! (pq, k=> v) # (same, using Pairs)
19
- dequeue! (pq) # remove and return the lowest priority key
20
- dequeue_pair! (pq) # remove and return the lowest priorty key and value
21
- peek (pq) # return the lowest priority key and value without removing it
17
+ push! (pq, k=> v) # insert the key k into pq with priority v
18
+ popfirst! (pq) # remove and return the lowest priority key and value
19
+ first (pq) # return the lowest priority key and value without removing it
22
20
delete! (pq, k) # delete the mapping for the given key in a priority queue, and return the priority queue.
23
21
```
24
22
@@ -28,8 +26,7 @@ inserted and priorities accessed or changed using indexing notation.
28
26
Examples:
29
27
30
28
``` jldoctest
31
- julia> # Julia code
32
- pq = PriorityQueue();
29
+ julia> pq = PriorityQueue();
33
30
34
31
julia> # Insert keys with associated priorities
35
32
pq["a"] = 10; pq["b"] = 5; pq["c"] = 15; pq
@@ -45,7 +42,9 @@ PriorityQueue{Any, Any, Base.Order.ForwardOrdering} with 3 entries:
45
42
"b" => 5
46
43
"c" => 15
47
44
```
48
- It is also possible to iterate over the priorities and elements of the queue in sorted order.
45
+
46
+ It is also possible to iterate over the priorities and elements of the queue in sorted order.
47
+
49
48
``` jldoctest
50
49
julia> pq = PriorityQueue("a"=>2, "b"=>1, "c"=>3)
51
50
PriorityQueue{String, Int64, Base.Order.ForwardOrdering} with 3 entries:
67
66
a
68
67
c
69
68
```
69
+
70
70
``` @meta
71
71
DocTestSetup = nothing
72
72
```
0 commit comments