ruby_collections 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 711f86e8d08effa34645af0d1f43560623b7e7ce
4
- data.tar.gz: 017ef4bd0f90379add0bd4653751206eac952ba7
3
+ metadata.gz: bb77ec104140f7d24e8026660ed783134ed5fb61
4
+ data.tar.gz: fd78dfe9362a368154da35a9e18032222e2ecfbb
5
5
  SHA512:
6
- metadata.gz: c1dcf3c5db4301b54cac67e4f17f179ca7b2e86db7fd53ed2dddea504355751e21e79e683a3f4232d752f60086aa22462962baa1358fbd9f7c9427c399dc805a
7
- data.tar.gz: e01f04a2860777d3fe4713cacaca963097de07e7c39e503c18bda965b5c8a5974652c58bb695578ccfccb9dee4218be315a6cc4860efe904df33e5c6326cd286
6
+ metadata.gz: aa6ea383b74b39620fe0502e88c7a65c255b95f895640d35bec2acf5ae0018bc550dba42f27cf3b27cbbd971144ab42771bc3f8887d43da2a27b5d016c513c24
7
+ data.tar.gz: 58f49231acf86c1f78bedc329cdb85a2e583f9e6cae4e5a39e4b4c9f0d3ca043c8ff388351781c713047892d991de61036089724bfe8f87637c5e7fb089aa786
data/README.md CHANGED
@@ -44,6 +44,24 @@ max_heap.max # => 1
44
44
 
45
45
  Similarly we can use MinHeap as well.
46
46
 
47
+ ### RubyCollections::Stack
48
+
49
+ ```ruby
50
+
51
+ stack = RubyCollections::Stack.new
52
+
53
+ stack.push(1) # => [1]
54
+
55
+ stack.push(4) # => [4, 1]
56
+
57
+ stack.top # => 4
58
+
59
+ stack.pop # => 4
60
+
61
+ stack.top # => 1
62
+
63
+ ```
64
+
47
65
  ## Development
48
66
 
49
67
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,2 +1,3 @@
1
1
  require "ruby_collections/max_heap"
2
- require "ruby_collections/min_heap"
2
+ require "ruby_collections/min_heap"
3
+ require "ruby_collections/stack"
@@ -0,0 +1,29 @@
1
+ module RubyCollections
2
+ class Stack
3
+
4
+ def initialize(arr = [])
5
+ @arr = arr
6
+ end
7
+
8
+ def size
9
+ @arr.size
10
+ end
11
+
12
+ def isEmpty?
13
+ @arr.size.zero?
14
+ end
15
+
16
+ def top
17
+ @arr[0]
18
+ end
19
+
20
+ def push(e)
21
+ @arr.unshift(e)
22
+ end
23
+
24
+ def pop
25
+ @arr.shift
26
+ end
27
+
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module RubyCollections
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_collections
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vikash Vikram
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-03-31 00:00:00.000000000 Z
11
+ date: 2015-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,6 +60,7 @@ files:
60
60
  - lib/ruby_collections/collections.rb
61
61
  - lib/ruby_collections/max_heap.rb
62
62
  - lib/ruby_collections/min_heap.rb
63
+ - lib/ruby_collections/stack.rb
63
64
  - lib/ruby_collections/version.rb
64
65
  - ruby_collections.gemspec
65
66
  homepage: https://github.com/vikashvikram/ruby_collections