Sha256: cc4cb421a8faeaee8b159506090a0544ccf968f233edcad83ec820d0d86fb401

Contents?: true

Size: 396 Bytes

Versions: 1

Compression:

Stored size: 396 Bytes

Contents

module RubyCollections
  class Stack

    #TODO: implement iterator
    #TODO: implement to_a

    def initialize(arr = [])
      @arr = arr
    end

    def size
      @arr.size
    end

    def isEmpty?
      @arr.size.zero?
    end

    def top
      @arr[0]
    end

    def push(e)
      @arr.unshift(e)
    end

    def pop
      @arr.shift
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby_collections-0.0.7 lib/ruby_collections/stack.rb