Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 7d9ca55b9a
Fetching contributors…

Cannot retrieve contributors at this time

41 lines (32 sloc) 0.537 kB
module RData
class Stack
def initialize
@selfStack = Array[
:top,
:size,
:clear,
:inspect,
:to_s
]
@selfStack[0] = :top
end
def push(x)
@selfStack[:top] = @selfStack[:top] + 1
@selfStack[@selfStack[:top]] = x
end
def top
return @selfStack[:top]
end
def pop
if self.is_empty?
raise 'Underflow'
else
@selfStack[:top] = @selfStack[:top] - 1
return @selfStack[:top + 1]
end
end
def is_empty?
(@selfStack[:top] == 0) ? 'true' : 'false'
end
end
end
Jump to Line
Something went wrong with that request. Please try again.