diff --git a/src/vector_of_arrays.jl b/src/vector_of_arrays.jl index 645a9e2..5ffc160 100644 --- a/src/vector_of_arrays.jl +++ b/src/vector_of_arrays.jl @@ -573,3 +573,5 @@ function consgroupedview(source::AbstractVector, target::NamedTuple{syms,<:NTupl elem_ptr = consgrouped_ptrs(source) map(X -> VectorOfVectors(X, elem_ptr), target) end + +Base.reduce(::typeof(vcat), V::VectorOfVectors) = flatview(V) \ No newline at end of file diff --git a/test/vector_of_arrays.jl b/test/vector_of_arrays.jl index 8ea4d00..bc27f6a 100644 --- a/test/vector_of_arrays.jl +++ b/test/vector_of_arrays.jl @@ -104,6 +104,21 @@ using ArraysOfArrays: full_consistency_checks, append_elemptr!, element_ptr B1_copy = @inferred(copy(B1)); B3_copy = @inferred(copy(B3)) append!(B1_copy, B3_copy) @test B1_copy.data == vcat(B1.data, B3.data) + + V1 = VectorOfVectors(ref_AoA1(Float32, 1)) + V2 = VectorOfVectors(ref_AoA1(Float32, 2)) + V3 = VectorOfVectors(ref_AoA1(Float32, 3)) + V4 = VectorOfVectors(ref_AoA1(Float32, 4)) + + @test reduce(vcat, V1) == reduce(vcat, Array(V1)) + @test reduce(vcat, V2) == reduce(vcat, Array(V2)) + @test reduce(vcat, V3) == reduce(vcat, Array(V3)) + @test reduce(vcat, V4) == reduce(vcat, Array(V4)) + + @test (@allocated reduce(vcat, V1)) == 0 + @test (@allocated reduce(vcat, V2)) == 0 + @test (@allocated reduce(vcat, V3)) == 0 + @test (@allocated reduce(vcat, V4)) == 0 end