stack_sourav 0.0.1 → 0.0.2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/stack_sourav.rb +56 -0
  3. metadata +4 -4
  4. data/lib/stack.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 40f096fa04eebe0e1d26f50120a48d3e93af180b
4
- data.tar.gz: 546f251ca93a9cce942da4be439617ddb0457b2b
3
+ metadata.gz: 825f6736f5ad1b575b5ced02c500ffb7fbd11c0d
4
+ data.tar.gz: 2324414dba7e4483d7117d00fb8598a6feb1776c
5
5
  SHA512:
6
- metadata.gz: 28bfe92721550cd5343733177a63ada1cfe21425d06418bf77340f17eb675fcb21c8655f06d6c3ec2f52c98ec59a07fa3f058a799cc41f85738fbdb31564b9e5
7
- data.tar.gz: f6c704143266c72587736538364bc81fd6b1c2f054810a3e0253c436de7ab7e5d5923653416287bee7be0c39a4964071183b15a7f0215558c47c1c15d026b082
6
+ metadata.gz: e1f2628cc1fbb6a39862d7322bd5b11757bb99609babee95baeaad1869a084ac2f83360126b7912b1751a14c1f7bc98f987f5220e9a480e72f41f16eaa311e4d
7
+ data.tar.gz: f67a7c98a026e6b198da391cbe8d4190de0fc4ea889c1f477f8419a5ff44e6fd295d46b10048584ca7b2c7ef3b7a065a3f5b5767357e2c7061692d0cd330a86a
@@ -0,0 +1,56 @@
1
+ require "linked_list"
2
+ class Stack
3
+ class Singly < LinkedList::Singly
4
+ attr_reader :top
5
+ def initialize(data=nil)
6
+ @head = @top = LinkedList::Node.new(data)
7
+ end
8
+
9
+ def push(data)
10
+ if is_empty?
11
+ @head.data =@top.data = data
12
+ else
13
+ new_node = LinkedList::Node.new(data)
14
+ @top.forward = new_node
15
+ @top = new_node
16
+ end
17
+ end
18
+
19
+ def add (data=nil)
20
+ puts "Does not work here"
21
+ end
22
+
23
+ def delete
24
+ puts "Doesnot Work here"
25
+ end
26
+
27
+ def edit
28
+ puts "Does not work here"
29
+ end
30
+
31
+ def is_empty?
32
+ true if @top.data == nil
33
+ end
34
+
35
+ def pop
36
+ poped_data = ''
37
+ if @head.data === @top.data
38
+ poped_data = @head.data
39
+ @head.data = @top.data = nil
40
+ else
41
+ node = @head
42
+ while (!(node.forward.equal? @top) )
43
+ node = node.forward
44
+ end
45
+ poped_node = @top
46
+ @top = node
47
+ @top.forward = nil
48
+ poped_data = poped_node.data
49
+ poped_node = nil
50
+ end
51
+ poped_data
52
+ end
53
+ end
54
+ class Doubly
55
+ end
56
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stack_sourav
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sourav Moitra
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.8
19
+ version: 0.0.11
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.8
26
+ version: 0.0.11
27
27
  description: This is a simple stack implementation for ruby it has array, singly and
28
28
  doubly linked list implementation
29
29
  email: sourav.moitr@gmail.con
@@ -31,7 +31,7 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - lib/stack.rb
34
+ - lib/stack_sourav.rb
35
35
  homepage: https://github.com/xw19/stack_sourav
36
36
  licenses:
37
37
  - MIT
@@ -1,6 +0,0 @@
1
- class Stack
2
- class Singly
3
- end
4
- class Doubly
5
- end
6
- end