Skip to content

Commit

Permalink
Merge pull request #381 from smldis/patch-1
Browse files Browse the repository at this point in the history
add `empty!(::Stack)` method
  • Loading branch information
oxinabox authored May 8, 2018
2 parents 0d2ef74 + 3112ac8 commit 691caea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/stack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ end

pop!(s::Stack) = pop!(s.store)

empty!(s::Stack) = (empty!(s.store); s)

start(st::Stack) = start(reverse_iter(st.store))
next(st::Stack, s) = next(reverse_iter(st.store), s)
done(st::Stack, s) = done(reverse_iter(st.store), s)
Expand Down
4 changes: 4 additions & 0 deletions test/test_stack_and_queue.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
@test isempty(s) == (i == n)
@test length(s) == n - i
end

s = Stack(Int,1)
push!(s, 10)
@test length(empty!(s)) == 0

#test that iter returns a LIFO collection

Expand Down

0 comments on commit 691caea

Please sign in to comment.