diff options
| author | mo khan <mo@mokhan.ca> | 2013-07-11 14:38:48 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2013-07-11 14:38:48 -0600 |
| commit | a122fdf2c6113f3e4709bcccac2b83251c17bdf4 (patch) | |
| tree | 9a8be598eb5a7eee54afc63c213d4e75607c67e7 /lib/data_structures/dynamic_array_stack.rb | |
| parent | fa2bc824f1e892c579847c8db2a7057da4c52ef2 (diff) | |
create a stack using a dynamic array.. (sort of cheating a bit)
Diffstat (limited to 'lib/data_structures/dynamic_array_stack.rb')
| -rw-r--r-- | lib/data_structures/dynamic_array_stack.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/data_structures/dynamic_array_stack.rb b/lib/data_structures/dynamic_array_stack.rb new file mode 100644 index 0000000..a709956 --- /dev/null +++ b/lib/data_structures/dynamic_array_stack.rb @@ -0,0 +1,13 @@ +class DynamicArrayStack + def initialize(items = []) + @items = items + end + + def pop + @items.pop + end + + def push(item) + @items.push(item) + end +end |
