stack.rb # Stackã¯ã¹ã¿ãã¯ãå®è£ ããã¯ã©ã¹ã§ããã # # SAMPLE # stack = Stack.new # stack.push "hoge" # stack.push "fuga" # p stack.pop #=> "fuga" # p stack.peek #=> "hoge" # p stack.size #=> 1 class Stack # ã¹ã¿ãã¯ã»ã¢ã³ãã¼ããã¼ class UnderflowError < RuntimeError; end # ã¹ã¿ãã¯ã»ãªã¼ãã¼ããã¼ class OverflowError < RuntimeError; end # ããã©ã«ãã®ã¹ã¿ãã¯å®¹é DEFAULT_CAPACITY = 10 # ã¹ã¿ãã¯ã®å¤§ãã attr_reader :size # ã¹ã¿ãã¯ã®å®¹é attr_reader :capacity #
{{#tags}}- {{label}}
{{/tags}}