mutable struct PreVector{T} last_ind::UInt64 v::Vector{T} PreVector{T}(N) where {T} = new{T}(UInt64(0), Vector{T}(undef, N)) end function push!(pv::PreVector{T}, x::T) where {T} pv.last_ind += 1 pv.v[pv.last_ind] = x return nothing end function reset!(pv::PreVector{T}) where {T} pv.last_ind = 0 return nothing end function iterate(pv::PreVector{T}, state=1) where {T} if state > pv.last_ind return nothing else return (pv.v[state], state + 1) end end