Sha256: 429adbca07b9126682e0ebc2b98216c75d2180063b3c7c3b6c57405c4d1a349d

Contents?: true

Size: 467 Bytes

Versions: 8

Compression:

Stored size: 467 Bytes

Contents

module Zadt
  class Stack
    def initialize
      @values = Array.new
    end

    def self.help
      Zadt::ADT::show_stack_help_message
    end

    def help
      Stack.help
    end

    def show
      @values
    end

    def push(val)
      @values.push(val)
      @values
    end

    def pop
      @values.pop
    end

    def peek
      @values.last
    end

    def length
      @values.length
    end

    def empty?
      @values.empty?
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
zadt-1.1.6 lib/zadt/AbstractDataTypes/StackQueue/Stack.rb
zadt-1.1.5 lib/zadt/AbstractDataTypes/StackQueue/Stack.rb
zadt-1.1.4 lib/zadt/AbstractDataTypes/StackQueue/Stack.rb
zadt-1.1.3 lib/zadt/AbstractDataTypes/StackQueue/Stack.rb
zadt-1.1.2 lib/zadt/AbstractDataTypes/StackQueue/Stack.rb
zadt-1.1.1 lib/zadt/AbstractDataTypes/StackQueue/Stack.rb
zadt-1.1.0 lib/zadt/AbstractDataTypes/StackQueue/Stack.rb
zadt-0.1.9 lib/zadt/AbstractDataTypes/StackQueue/Stack.rb