Skip to content

Commit 86ab26e

Browse files
PraneethJainbarche
authored andcommitted
feat: StdFill for lists
1 parent 17e1d59 commit 86ab26e

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

src/StdLib.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ include("StdLib/StdValArray.jl")
3838
include("StdLib/StdVector.jl")
3939

4040

41-
function Base.fill!(v::T, x) where {T<:Union{StdVector,StdValArray,StdDeque}}
41+
function Base.fill!(v::T, x) where {T<:Union{StdList,StdForwardList}}
4242
StdFill(v, x)
4343
return v
4444
end

test/stdlib.jl

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -613,31 +613,26 @@ end
613613

614614
@static if isdefined(StdLib, :HAS_RANGES)
615615

616-
@testset "StdFill" begin
617-
@testset "fill StdVector" begin
618-
v = StdVector{Int64}([1, 2, 3, 4, 5])
616+
@testset "STL algorithms" begin
617+
@testset "fill StdList" begin
618+
v = StdList{Int64}()
619+
for x in 1:10
620+
push!(v, x)
621+
end
619622
fill!(v, 1)
620623
for x in v
621624
@test x == 1
622625
end
623626
end
624627

625-
@testset "fill StdValArray" begin
626-
v = StdValArray([1.0, 2.0, 3.0])
627-
fill!(v, 2)
628-
for x in v
629-
@test x == 2
630-
end
631-
end
632-
633-
@testset "fill StdDeque" begin
634-
deq = StdDeque{Int64}()
635-
for i = 1:10
636-
push!(deq, i)
628+
@testset "fill StdForwardList" begin
629+
v = StdForwardList{Int64}()
630+
for x in 1:10
631+
pushfirst!(v, x)
637632
end
638-
fill!(deq, 3)
639-
for x in deq
640-
@test x == 3
633+
fill!(v, 1)
634+
for x in v
635+
@test x == 1
641636
end
642637
end
643638
end

0 commit comments

Comments
 (0)