data_struct_list 0.1.3 → 0.1.4

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: 7590734c44c0e0f35e3803561a2b6c8aefb952db
4
- data.tar.gz: b4ec818256d47b82b329182a1bf99d47812b4a6b
3
+ metadata.gz: e90e19c776d8ede30f8ad213c72d69558c9b491c
4
+ data.tar.gz: 2a7de64e1c91772e2e56ce6c097b4d7f6cd3f879
5
5
  SHA512:
6
- metadata.gz: 70ee825e24c99ef1435a93f26abca67094d8b4bf4c086a85f372c0208c640879fb1e9f30b835cd20789973348679205addd10e99b7d2185ed32f135697734fbd
7
- data.tar.gz: bd9725af655e3eb74e26baa265d7db80a9726de22c733348657214801289a75f6e09345c54b6081c8f4266676f98d754b0f94243d7871230f5951005f50b55f9
6
+ metadata.gz: 9cad630ab14ea8ec77047ac082223f114133469ae48b5fda4de3f45a7751ffc12c12f9d3953b6c33cda9794eb08a84985627a3fbcfb566f369260ca7873ca38b
7
+ data.tar.gz: 20be29292c9cd18cffbc9b2e53ed4abe24cedefb62f5c3764937b77c1fe0ac359360b7625cab385782ba6f665ad719c8d56355e6e06c4d63cacc1f478eb84b1c
data/README.md CHANGED
@@ -5,8 +5,8 @@ Most of data structure class uses C, python or Java to teach, this lib was made
5
5
  ## TODO
6
6
  - [x] Stack
7
7
  - [x] Simple Linked List
8
- - [ ] Double Linked List
9
- - [ ] Cycle Simple Linked List
8
+ - [ ] Double Linked List <- Comming soon
9
+ - [x] Cycle Simple Linked List
10
10
  - [ ] Cycle Double Linked List
11
11
 
12
12
  ## Installation
@@ -54,7 +54,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
54
54
 
55
55
  ## Contributing
56
56
 
57
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/data_struct_list. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/joaomarcuslf/data_struct_list. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
58
58
 
59
59
 
60
60
  ## License
Binary file
@@ -1,3 +1,3 @@
1
1
  module DataStructList
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -83,17 +83,6 @@ module DataStructList
83
83
 
84
84
  class SimpleLinkedList < Stack
85
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
-
97
86
  def remove(id)
98
87
  elm = @first
99
88
  aux = @first
@@ -115,7 +104,40 @@ module DataStructList
115
104
  if @last == elm then @last = aux end
116
105
  elm = nil
117
106
  end
107
+ end
108
+ end
109
+
110
+ class CycleSimpleLinkedList < SimpleLinkedList
111
+ def find(id)
112
+ if @first == nil then return @first end
118
113
 
114
+ elm = @first
115
+
116
+ until elm == @last.next
117
+ if elm.id == id then break end
118
+ elm = elm.next
119
+ end
120
+
121
+ return elm
122
+ end
123
+
124
+ def insert(hash)
125
+ if @head.quant == 0 then
126
+ @head.next = Node.new(hash)
127
+ @first = @head.next
128
+ @last = @head.next
129
+ @head.quant += 1
130
+ @first.next = @last
131
+
132
+ else
133
+ @last.next = Node.new(hash)
134
+ @last = @last.next
135
+ @head.quant += 1
136
+ end
137
+
138
+ @last.next = @first
139
+
140
+ return @last.id
119
141
  end
120
142
  end
121
143
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_struct_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Marcus de Lemos Fernandes
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-24 00:00:00.000000000 Z
11
+ date: 2016-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -57,6 +57,7 @@ files:
57
57
  - bin/setup
58
58
  - data_struct_list-0.1.0.gem
59
59
  - data_struct_list-0.1.1.gem
60
+ - data_struct_list-0.1.3.gem
60
61
  - data_struct_list.gemspec
61
62
  - lib/data_struct_list.rb
62
63
  - lib/data_struct_list/version.rb
@@ -80,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
81
  version: '0'
81
82
  requirements: []
82
83
  rubyforge_project:
83
- rubygems_version: 2.4.8
84
+ rubygems_version: 2.4.5
84
85
  signing_key:
85
86
  specification_version: 4
86
87
  summary: This is an lib for using Data Structure Architecture.