class Stack
Attributes
store[R]
Public Class Methods
new()
click to toggle source
# File lib/data_structures/stack.rb, line 2 def initialize @store = Array.new end
Public Instance Methods
<<(el)
click to toggle source
# File lib/data_structures/stack.rb, line 32 def <<(el) @store << el end
==(other_stack)
click to toggle source
# File lib/data_structures/stack.rb, line 18 def ==(other_stack) return false unless other_stack.is_a?(Stack) @store == other_stack.send(:store) end
empty?()
click to toggle source
# File lib/data_structures/stack.rb, line 23 def empty? @store.empty? end
include?(el)
click to toggle source
# File lib/data_structures/stack.rb, line 48 def include?(el) @store.include?(el) end
inspect()
click to toggle source
# File lib/data_structures/stack.rb, line 14 def inspect @store end
length()
click to toggle source
# File lib/data_structures/stack.rb, line 44 def length @store.length end
peek()
click to toggle source
# File lib/data_structures/stack.rb, line 40 def peek @store.last end
pop()
click to toggle source
# File lib/data_structures/stack.rb, line 36 def pop @store.pop end
push(el)
click to toggle source
# File lib/data_structures/stack.rb, line 27 def push(el) @store.push(el) self end
to_a()
click to toggle source
# File lib/data_structures/stack.rb, line 6 def to_a Array.new(@store) end
to_s()
click to toggle source
# File lib/data_structures/stack.rb, line 10 def to_s @store end