I want to write a better performance array, don’t know if there is a ready-made one?
I wrote a prototype
struct Arr{T, N} <: AbstractArray{T, N}
ilength::Int64
data::Array{T, N}
end
Base.length(A::Arr) = A.ilength
Base.empty!(A::Arr) =A.ilength=0
Base.push!(A::Arr,x)=(A.data[A.ilength+1]=x;A.ilength+=1)
This array does not empty the data when empty! is executed, but ilength=0, which avoids memory allocation, so the speed should be faster
No memory allocation is required when executing push!
I think someone has written such an array, but I didn’t find a ready-made one. I hope someone can tell, thank you
I took a look at StaticArrays, but he recommends no more than 100 elements