Skip to content

Commit 2313800

Browse files
update iteration protocol and add working vec
1 parent 5a01f9d commit 2313800

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/vector_of_array.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ end
4747

4848
# The iterator will be over the subarrays of the container, not the individual elements
4949
# unlike an true AbstractArray
50-
Base.start(VA::AbstractVectorOfArray{T, N}) where {T, N} = 1
51-
Base.next(VA::AbstractVectorOfArray{T, N}, state) where {T, N} = (VA[state], state + 1)
52-
Base.done(VA::AbstractVectorOfArray{T, N}, state) where {T, N} = state >= length(VA.u) + 1
50+
function Base.iterate(VA::AbstractVectorOfArray,state=1)
51+
state >= length(VA.u) + 1 ? nothing : (VA[state], state + 1)
52+
end
5353
tuples(VA::DiffEqArray) = tuple.(VA.t,VA.u)
5454

5555
# Growing the array simply adds to the container vector
@@ -84,6 +84,7 @@ end
8484

8585
# conversion tools
8686
vecarr_to_vectors(VA::AbstractVectorOfArray) = [VA[i,:] for i in eachindex(VA[1])]
87+
Base.vec(VA::AbstractVectorOfArray) = vec(convert(Array,VA)) # Allocates
8788

8889
# make it show just like its data
8990
Base.show(io::IO, x::AbstractVectorOfArray) = show(io, x.u)

0 commit comments

Comments
 (0)