We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1c6c2ad commit eee0d59Copy full SHA for eee0d59
src/stack.jl
@@ -43,15 +43,16 @@ Get the top item from the stack. Sometimes called peek.
43
Base.first(s::Stack) = last(s.store)
44
Base.last(s::Stack) = first(s.store)
45
46
-function Base.push!(s::Stack, x)
47
- push!(s.store, x)
48
- return s
49
-end
+Base.push!(s::Stack, x) = (push!(s.store, x); s)
+Base.pushfirst!(s::Stack, x) = (pushfirst!(s.store, x); s)
50
51
Base.pop!(s::Stack) = pop!(s.store)
+Base.popfirst!(s::Stack) = pop!first(s.store)
52
53
Base.empty!(s::Stack) = (empty!(s.store); s)
54
+Base.collect(s::Stack) = collect(s.store)
55
+
56
Base.iterate(st::Stack, s...) = iterate(Iterators.reverse(st.store), s...)
57
58
Iterators.reverse(s::Stack{T}) where {T} = DequeIterator{T}(s.store)
0 commit comments