# How to create a priority queue with a certain type of key and priority?

**URL:** https://discourse.julialang.org/t/how-to-create-a-priority-queue-with-a-certain-type-of-key-and-priority/24604
**Category:** General Usage
**Created:** [May 25, 2019, 4:26pm UTC](https://discourse.julialang.org/t/how-to-create-a-priority-queue-with-a-certain-type-of-key-and-priority/24604 "2019-05-25T16:26:51Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)
#### Post date: [May 25, 2019, 4:26pm UTC](https://discourse.julialang.org/t/how-to-create-a-priority-queue-with-a-certain-type-of-key-and-priority/24604/1 "2019-05-25T16:26:51Z")

</div>

```julia-auto
mutable struct Event
     time::Float64
     Event = new(-1.0)
end

```

# create a priority queue with keys of type Event and priorities of type Float64

`pq = PriorityQueue(Event, Float64)`

Then, I got the following error.  
"MethodError: no method matching PriorityQueue(::Type{Event}, ::Type{Float64})

Could anyone help out with this code?

---

<div class="post-metadata">

### Author: ![dellison](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@dellison](https://discourse.julialang.org/u/dellison)
#### Post date: [May 25, 2019, 4:47pm UTC](https://discourse.julialang.org/t/how-to-create-a-priority-queue-with-a-certain-type-of-key-and-priority/24604/2 "2019-05-25T16:47:24Z")

</div>

Something like this?

```julia
using DataStructures

mutable struct Event
     time::Float64
end

pq = PriorityQueue{Event, Float64}()

```
