is fast, but pushing/popping will start at the end
> push!(cur_array_1, 1)
[ 0 0 0 0 1 ]
A more useful data structure would then be an array list:
cur_array_2 = []
> push!(cur_array_2, 1)
[ 1 ]
This begs the question, is there a fixed-length array-list data structure that stores a cur_index to allow pushing and popping from the beginning – i.e. a growing array that is rpadded by 0’s?
Ah, I see, thanks for clarification. I don’t know any existing data structure for it, but it seems pretty easy to implement:
mutable struct ArrayList{T}
data::Vector{T}
idx::Int
end
function Base.push!(a::ArrayList, x)
if a.idx >= length(a.data)
error("ArrayList is full, can't push new values")
else
a.idx += 1
a.data[a.idx] = x
end
end