double_linked_list 0.4.0 → 0.4.1
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 +4 -4
- data/README.md +12 -12
- data/lib/double_linked_list/element.rb +1 -5
- data/lib/double_linked_list/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09299281dc5a6ae2528a842346c6cdd44155511b'
|
4
|
+
data.tar.gz: eab934adfa9f7f7fc1515355daa62f381fc8f538
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca6141327f7c1df6477f876d6f76785476094cb32f93b3bcd0538923aa949fb35999623484b4d7b948c99769c58f5ffc7186c4794ba24e681d9b7b4e4ec74a27
|
7
|
+
data.tar.gz: 1dfb1aa2d152cb3e06d61d9580960048c970af785aa52d954cf26dba5c4011d3e0c8f2587dd12b6786da5e44de1320dda6900036545847ca1c5c98a44ed68ac8
|
data/README.md
CHANGED
@@ -80,7 +80,7 @@ users = [
|
|
80
80
|
User.new(3)
|
81
81
|
]
|
82
82
|
llist = DoubleLinkedList.from_a(users)
|
83
|
-
llist.find_by{ |elem| elem.
|
83
|
+
llist.find_by{ |elem| elem.id == 1 }.id #=> 1
|
84
84
|
```
|
85
85
|
|
86
86
|
__append:__
|
@@ -130,8 +130,8 @@ The first element of the splitted array are the elememts that return true in the
|
|
130
130
|
```ruby
|
131
131
|
llist = DoubleLinkedList.from_a(1, 2, 3, 4)
|
132
132
|
chunked = llist.chunk_by do |e, current_llist|
|
133
|
-
|
134
|
-
end
|
133
|
+
e.datum == 3 && current_llist.head.datum == 1
|
134
|
+
end
|
135
135
|
chunked.first.is_a? DoubleLinkedList #=> true
|
136
136
|
chunked.first.head.datum #=> 1
|
137
137
|
chunked.first.last.datum #=> 2
|
@@ -144,10 +144,10 @@ A custom dll can be provided to enhance dll outputs
|
|
144
144
|
class CustomDLL < DoubleLinkedList; end
|
145
145
|
|
146
146
|
llist = DoubleLinkedList.from_a(1, 2, 3, 4)
|
147
|
-
chunked = llist.chunk_by do |e, current_llist|
|
148
|
-
|
149
|
-
end
|
150
|
-
chunked.first.is_a?
|
147
|
+
chunked = llist.chunk_by(CustomDLL) do |e, current_llist|
|
148
|
+
e.datum == 3 && current_llist.head.datum == 1
|
149
|
+
end
|
150
|
+
chunked.first.is_a?(CustomDLL) #=> true
|
151
151
|
```
|
152
152
|
|
153
153
|
__select_by:__
|
@@ -158,10 +158,10 @@ In the block must be returned a `DoubleLinkedList::Sequence` instance and head a
|
|
158
158
|
```ruby
|
159
159
|
llist = DoubleLinkedList.from_a(1, 2, 3, 4)
|
160
160
|
select = llist.select_by do |e|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
end
|
161
|
+
if e.datum == 2 && e.next.datum == 3
|
162
|
+
DoubleLinkedList::Sequence.new(head: e, last: e.next)
|
163
|
+
end
|
164
|
+
end
|
165
165
|
select.is_a? Array #=> true
|
166
166
|
select.first.is_a? DoubleLinkedList #=> true
|
167
167
|
select.map{|ll| ll.to_a } #=> [[2, 3]]
|
@@ -169,7 +169,7 @@ select.map{|ll| ll.to_a } #=> [[2, 3]]
|
|
169
169
|
|
170
170
|
## Development
|
171
171
|
|
172
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `
|
172
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
173
173
|
|
174
174
|
To install this gem onto your local machine, run `bundle exec rake install`. [rubygems.org](https://rubygems.org).
|
175
175
|
|
@@ -104,11 +104,7 @@ class DoubleLinkedList
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def method_missing(method, *args, &block)
|
107
|
-
|
108
|
-
datum.send(method, *args, &block)
|
109
|
-
else
|
110
|
-
super
|
111
|
-
end
|
107
|
+
datum.send(method, *args, &block)
|
112
108
|
end
|
113
109
|
|
114
110
|
def respond_to_missing?(method_name, include_private = false)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: double_linked_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artur Pañach
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|