Skip to content

Commit

Permalink
Add append! for AbstractVector second argument (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasnoack authored and nalimilan committed Apr 4, 2018
1 parent 8dc1dff commit 926e76a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/IndirectArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,11 @@ function Base.append!(A::IndirectArray{T,1}, B::IndirectArray{T,1}) where T
return A
end

function Base.append!(A::IndirectArray{<:Any,1}, B::AbstractVector)
for b in B
push!(A, b)
end
return A
end

end # module
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ xc[2], xc[3] = RGB(0,1,0), RGB(0,1,1)
@test append!(x, x) == IndirectArray([colors[:]; colors[:]])
@test append!(x, IndirectArray([RGB(1,0,0), RGB(1,1,0)])) ==
IndirectArray([colors[:]; colors[:]; [RGB(1,0,0), RGB(1,1,0)]])
# Append with non-IndirectArray
@test append!(IndirectArray(colors[:]), IndirectArray(colors[:])) ==
append!(IndirectArray(colors[:]), colors[:])

# Bounds checking upon construction
index_ob = copy(index0)
Expand Down

0 comments on commit 926e76a

Please sign in to comment.