@@ -220,6 +220,9 @@ Base.IndexStyle(::Type{<:AbstractVectorOfArray}) = IndexCartesian()
220220@inline function Base. eachindex (VA:: AbstractVectorOfArray )
221221 return eachindex (VA. u)
222222end
223+ @inline function Base. eachindex (:: IndexLinear , VA:: AbstractVectorOfArray{T,N,<:AbstractVector{T}} ) where {T, N}
224+ return eachindex (IndexLinear (), VA. u)
225+ end
223226@inline Base. IteratorSize (:: Type{<:AbstractVectorOfArray} ) = Base. HasLength ()
224227@inline Base. first (VA:: AbstractVectorOfArray ) = first (VA. u)
225228@inline Base. last (VA:: AbstractVectorOfArray ) = last (VA. u)
@@ -245,7 +248,11 @@ __parameterless_type(T) = Base.typename(T).wrapper
245248Base. @propagate_inbounds function _getindex (A:: AbstractVectorOfArray{T, N} ,
246249 :: NotSymbolic , I:: Colon... ) where {T, N}
247250 @assert length (I) == ndims (A. u[1 ]) + 1
248- vecs = vec .(A. u)
251+ vecs = if N == 1
252+ A. u
253+ else
254+ vec .(A. u)
255+ end
249256 return Adapt. adapt (__parameterless_type (T),
250257 reshape (reduce (hcat, vecs), size (A. u[1 ])... , length (A. u)))
251258end
@@ -496,6 +503,16 @@ function Base.stack(VA::AbstractVectorOfArray; dims = :)
496503end
497504
498505# AbstractArray methods
506+ function Base. view (A:: AbstractVectorOfArray{T,N,<:AbstractVector{T}} , I:: Vararg{Any, M} ) where {T,N,M}
507+ @inline
508+ if length (I) == 1
509+ J = map (i-> Base. unalias (A,i), to_indices (A, I))
510+ elseif length (I) == 2 && (I[1 ] == Colon () || I[1 ] == 1 )
511+ J = map (i-> Base. unalias (A,i), to_indices (A, Base. tail (I)))
512+ end
513+ @boundscheck checkbounds (A, J... )
514+ SubArray (IndexStyle (A), A, J, Base. index_dimsum (J... ))
515+ end
499516function Base. view (A:: AbstractVectorOfArray , I:: Vararg{Any,M} ) where {M}
500517 @inline
501518 J = map (i-> Base. unalias (A,i), to_indices (A, I))
509526Base. isassigned (VA:: AbstractVectorOfArray , idxs... ) = checkbounds (Bool, VA, idxs... )
510527Base. check_parent_index_match (:: RecursiveArrayTools.AbstractVectorOfArray{T,N} , :: NTuple{N,Bool} ) where {T,N} = nothing
511528Base. ndims (:: AbstractVectorOfArray{T, N} ) where {T, N} = N
529+
530+ function Base. checkbounds (:: Type{Bool} , VA:: AbstractVectorOfArray{T, N, <:AbstractVector{T}} , idxs... ) where {T, N}
531+ if length (idxs) == 2 && (idxs[1 ] == Colon () || idxs[1 ] == 1 )
532+ return checkbounds (Bool, VA. u, idxs[2 ])
533+ end
534+ return checkbounds (Bool, VA. u, idxs... )
535+ end
512536function Base. checkbounds (:: Type{Bool} , VA:: AbstractVectorOfArray , idx... )
513537 if checkbounds (Bool, VA. u, last (idx))
514538 if last (idx) isa Integer
0 commit comments