data_struct_list 0.1.1 → 0.1.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: 39a466ba2987aab3a176791001a5ff67a45d09ac
4
- data.tar.gz: 1cce751b40624cb7cc4938b11fc14862c0ab8ffb
3
+ metadata.gz: 7590734c44c0e0f35e3803561a2b6c8aefb952db
4
+ data.tar.gz: b4ec818256d47b82b329182a1bf99d47812b4a6b
5
5
  SHA512:
6
- metadata.gz: 72797517a89ccf5c65187fe7343e2f24d214e7da2961e3bb35bba5a16467588f2139f07fed21f667e1d034af7219a4e900238326ab88b93a851ca407d49d0951
7
- data.tar.gz: c125655d071859a9b3b3dc0a21432b42fcdd44f12fa660396c2ee6a09712bffd648c4aa82351ca2b303bc2e54cca33bac79b881ddbbda9780fe9bb26b940e3ba
6
+ metadata.gz: 70ee825e24c99ef1435a93f26abca67094d8b4bf4c086a85f372c0208c640879fb1e9f30b835cd20789973348679205addd10e99b7d2185ed32f135697734fbd
7
+ data.tar.gz: bd9725af655e3eb74e26baa265d7db80a9726de22c733348657214801289a75f6e09345c54b6081c8f4266676f98d754b0f94243d7871230f5951005f50b55f9
data/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  Most of data structure class uses C, python or Java to teach, this lib was made to add some Data Structure Architecture using ruby syntax.
4
4
 
5
5
  ## TODO
6
+ - [x] Stack
6
7
  - [x] Simple Linked List
7
8
  - [ ] Double Linked List
8
9
  - [ ] Cycle Simple Linked List
@@ -59,4 +60,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
59
60
  ## License
60
61
 
61
62
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
62
-
@@ -21,12 +21,12 @@ module DataStructList
21
21
  end
22
22
  end
23
23
 
24
- class SimpleLinkedList
24
+ class Stack
25
25
  attr_reader :first, :last, :head
26
26
  def initialize
27
27
  @head = Head.new
28
- @first = nil
29
28
  @last = nil
29
+ @first = nil
30
30
  end
31
31
 
32
32
  def insert(hash)
@@ -56,6 +56,44 @@ module DataStructList
56
56
  return elm
57
57
  end
58
58
 
59
+ def remove
60
+ return nil if @head.quant == 0
61
+
62
+ elm = @head.next
63
+ @head.quant-=1
64
+
65
+ until elm.next == @last
66
+ if elm == @last then break end
67
+ elm = elm.next
68
+ end
69
+
70
+ if @first == @last then
71
+ @first = nil
72
+ @last = nil
73
+ @head.next = nil
74
+ return nil
75
+ end
76
+
77
+ aux = @last
78
+ @last = elm
79
+ elm.next = nil
80
+ aux = nil
81
+ end
82
+ end
83
+
84
+ class SimpleLinkedList < Stack
85
+
86
+ def find(id)
87
+ elm = @first
88
+
89
+ until elm == nil
90
+ if elm.id == id then break end
91
+ elm = elm.next
92
+ end
93
+
94
+ return elm
95
+ end
96
+
59
97
  def remove(id)
60
98
  elm = @first
61
99
  aux = @first
@@ -1,4 +1,3 @@
1
1
  module DataStructList
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
  end
4
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_struct_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Marcus de Lemos Fernandes
@@ -56,6 +56,7 @@ files:
56
56
  - bin/console
57
57
  - bin/setup
58
58
  - data_struct_list-0.1.0.gem
59
+ - data_struct_list-0.1.1.gem
59
60
  - data_struct_list.gemspec
60
61
  - lib/data_struct_list.rb
61
62
  - lib/data_struct_list/version.rb
@@ -79,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
80
  version: '0'
80
81
  requirements: []
81
82
  rubyforge_project:
82
- rubygems_version: 2.4.5
83
+ rubygems_version: 2.4.8
83
84
  signing_key:
84
85
  specification_version: 4
85
86
  summary: This is an lib for using Data Structure Architecture.