# Create an empty array, then insert (Priority Queue)

**URL:** https://discourse.julialang.org/t/create-an-empty-array-then-insert-priority-queue/63425
**Category:** New to Julia
**Tags:** array
**Created:** [June 23, 2021, 8:54am UTC](https://discourse.julialang.org/t/create-an-empty-array-then-insert-priority-queue/63425 "2021-06-23T08:54:42Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [June 23, 2021, 11:34am UTC](https://discourse.julialang.org/t/create-an-empty-array-then-insert-priority-queue/63425/5 "2021-06-23T11:34:28Z")

</div>

You definitely do not need to define your own type to do this. You can use a `Vector{Any}` which can hold any kind of object.

```julia
julia> A = [] # Vector{Any} by default
Any[]

julia> insert!(A, 1, ("toto",))
1-element Vector{Any}:
 ("toto",)

julia> insert!(A, 1, ("titi", 1.0))
2-element Vector{Any}:
 ("titi", 1.0)
 ("toto",)

```

The `Vector` data structure is a contiguous one-dimensional array, but you can add and remove items at the front and back, so it works in terms of API for what you want. On modern hardware, a contiguous array is hard to beat and it’s very hard to find a use case where a linked list is better, even for operations that are in principle O(n) for a vector and O(1) for a linked list: [Bjarne Stroustrup: Why you should avoid Linked Lists - YouTube](https://www.youtube.com/watch?v=YQs6IC-vgmo).

---

_[View the full topic](https://discourse.julialang.org/t/create-an-empty-array-then-insert-priority-queue/63425)._
