skn_utils 3.3.0 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/skn_utils/lists/circular_linked_list.rb +1 -0
- data/lib/skn_utils/lists/doubly_linked_list.rb +1 -0
- data/lib/skn_utils/lists/linked_list.rb +1 -0
- data/lib/skn_utils/version.rb +1 -1
- data/spec/lib/skn_utils/lists/Circular_linked_list_spec.rb +16 -16
- data/spec/lib/skn_utils/lists/doubly_linked_list_spec.rb +13 -13
- data/spec/lib/skn_utils/lists/linked_list_spec.rb +21 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb741d6ef4692e94ee1f7649bc655bdac1fcc068
|
4
|
+
data.tar.gz: da995ac562de18cea5b4c8950e6ae37349926947
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c9c7ce7644387a73836ceb91fa9efd184c65e0ad8ca35702be2539d94aff52edaac42b579fa18eb7a858d3283d6fd103c27aabf6210f5d8b2b0419052a9e4c3
|
7
|
+
data.tar.gz: 5623acf078e653111cc05a56e5a195758e9ef8908722a71ae3ac8a1ba31340fcbbe204ae9612a8140540863d4765dd4cd21d6b4fc9473ae7ee1c7dd1cf8b5d4f
|
data/lib/skn_utils/version.rb
CHANGED
@@ -18,7 +18,7 @@ RSpec.describe SknUtils::Lists::CircularLinkedList, "Circular LinkedList " do
|
|
18
18
|
end
|
19
19
|
it "can be initialized with one or more initial values" do
|
20
20
|
list = described_class.new(10,100,100)
|
21
|
-
expect(list.current).to eq(
|
21
|
+
expect(list.current).to eq(10)
|
22
22
|
end
|
23
23
|
it "is initially empty?" do
|
24
24
|
expect(subject.empty?).to be true
|
@@ -35,11 +35,11 @@ RSpec.describe SknUtils::Lists::CircularLinkedList, "Circular LinkedList " do
|
|
35
35
|
expect(list.first).to eq(10)
|
36
36
|
expect(list.next).to eq(20)
|
37
37
|
end
|
38
|
-
it "#current returns the
|
39
|
-
expect(list.current).to eq(
|
38
|
+
it "#current returns the first value " do
|
39
|
+
expect(list.current).to eq(10)
|
40
40
|
end
|
41
41
|
it "#prev returns the prior value" do
|
42
|
-
expect(list.prev).to eq(
|
42
|
+
expect(list.prev).to eq(100)
|
43
43
|
end
|
44
44
|
it "#last returns the last value" do
|
45
45
|
expect(list.last).to eq(100)
|
@@ -119,13 +119,13 @@ RSpec.describe SknUtils::Lists::CircularLinkedList, "Circular LinkedList " do
|
|
119
119
|
let(:list) { described_class.new(10,20, 30, 40, 50, 60, 70, 80, 90, 100) }
|
120
120
|
|
121
121
|
it "#at_index(-999) fails and returns the current element. " do
|
122
|
-
expect(list.at_index(-999)).to eq(
|
122
|
+
expect(list.at_index(-999)).to eq(10)
|
123
123
|
end
|
124
124
|
it "#at_index(0) fails and returns the current element. " do
|
125
|
-
expect(list.at_index(0)).to eq(
|
125
|
+
expect(list.at_index(0)).to eq(10)
|
126
126
|
end
|
127
127
|
it "#at_index(999) fails and returns the current element. " do
|
128
|
-
expect(list.at_index(999)).to eq(
|
128
|
+
expect(list.at_index(999)).to eq(10)
|
129
129
|
end
|
130
130
|
it "#at_index(n) returns the proper element. " do
|
131
131
|
expect(list.at_index(1)).to eq(10)
|
@@ -139,22 +139,22 @@ RSpec.describe SknUtils::Lists::CircularLinkedList, "Circular LinkedList " do
|
|
139
139
|
expect(only.at_index(-10)).to eq(55)
|
140
140
|
end
|
141
141
|
|
142
|
-
it "#nth(-999)
|
143
|
-
expect(list.nth(-999)).to eq(
|
142
|
+
it "#nth(-999) fails and returns current initialization value." do
|
143
|
+
expect(list.nth(-999)).to eq(10)
|
144
144
|
end
|
145
145
|
it "#nth(0) returns current value, or last initialization value." do
|
146
|
-
expect(list.nth(0)).to eq(
|
146
|
+
expect(list.nth(0)).to eq(10)
|
147
147
|
end
|
148
|
-
it "#nth(999) returns
|
149
|
-
expect(list.nth(999)).to eq(
|
148
|
+
it "#nth(999) fails and returns current initialization value." do
|
149
|
+
expect(list.nth(999)).to eq(10)
|
150
150
|
end
|
151
|
-
it "#current equals
|
152
|
-
expect(list.current).to eq(
|
151
|
+
it "#current equals first initialization value." do
|
152
|
+
expect(list.current).to eq(10)
|
153
153
|
end
|
154
|
-
it "#next after initialization
|
155
|
-
expect(list.next).to eq(10)
|
154
|
+
it "#next after initialization returns correctly. " do
|
156
155
|
expect(list.next).to eq(20)
|
157
156
|
expect(list.next).to eq(30)
|
157
|
+
expect(list.next).to eq(40)
|
158
158
|
end
|
159
159
|
it "#prev after first returns proper sequence of values. " do
|
160
160
|
expect(list.first).to eq(10)
|
@@ -18,7 +18,7 @@ RSpec.describe SknUtils::Lists::DoublyLinkedList, "Double-Ended LinkedList " do
|
|
18
18
|
end
|
19
19
|
it "can be initialized with one or more initial values" do
|
20
20
|
list = described_class.new(10,100,100)
|
21
|
-
expect(list.current).to eq(
|
21
|
+
expect(list.current).to eq(10)
|
22
22
|
end
|
23
23
|
it "is initially empty?" do
|
24
24
|
expect(subject.empty?).to be true
|
@@ -35,11 +35,11 @@ RSpec.describe SknUtils::Lists::DoublyLinkedList, "Double-Ended LinkedList " do
|
|
35
35
|
expect(list.first).to eq(10)
|
36
36
|
expect(list.next).to eq(20)
|
37
37
|
end
|
38
|
-
it "#current returns the
|
39
|
-
expect(list.current).to eq(
|
38
|
+
it "#current returns the first value" do
|
39
|
+
expect(list.current).to eq(10)
|
40
40
|
end
|
41
41
|
it "#prev returns the prior value" do
|
42
|
-
expect(list.prev).to eq(
|
42
|
+
expect(list.prev).to eq(10)
|
43
43
|
end
|
44
44
|
it "#last returns the last value" do
|
45
45
|
expect(list.last).to eq(100)
|
@@ -119,13 +119,13 @@ RSpec.describe SknUtils::Lists::DoublyLinkedList, "Double-Ended LinkedList " do
|
|
119
119
|
let(:list) { described_class.new(10,20, 30, 40, 50, 60, 70, 80, 90, 100) }
|
120
120
|
|
121
121
|
it "#at_index(-999) fails and returns the current element. " do
|
122
|
-
expect(list.at_index(-999)).to eq(
|
122
|
+
expect(list.at_index(-999)).to eq(10)
|
123
123
|
end
|
124
124
|
it "#at_index(0) fails and returns the current element. " do
|
125
|
-
expect(list.at_index(0)).to eq(
|
125
|
+
expect(list.at_index(0)).to eq(10)
|
126
126
|
end
|
127
127
|
it "#at_index(999) fails and returns the current element. " do
|
128
|
-
expect(list.at_index(999)).to eq(
|
128
|
+
expect(list.at_index(999)).to eq(10)
|
129
129
|
end
|
130
130
|
it "#at_index(n) returns the proper element. " do
|
131
131
|
expect(list.at_index(1)).to eq(10)
|
@@ -143,18 +143,18 @@ RSpec.describe SknUtils::Lists::DoublyLinkedList, "Double-Ended LinkedList " do
|
|
143
143
|
expect(list.nth(-999)).to eq(10)
|
144
144
|
end
|
145
145
|
it "#nth(0) returns current value, or last initialization value." do
|
146
|
-
expect(list.nth(0)).to eq(
|
146
|
+
expect(list.nth(0)).to eq(10)
|
147
147
|
end
|
148
148
|
it "#nth(999) returns last initialization value." do
|
149
149
|
expect(list.nth(999)).to eq(100)
|
150
150
|
end
|
151
|
-
it "#current equals
|
152
|
-
expect(list.current).to eq(
|
151
|
+
it "#current equals first initialization value." do
|
152
|
+
expect(list.current).to eq(10)
|
153
153
|
end
|
154
154
|
it "#next after initialization equals last initialization value. " do
|
155
|
-
expect(list.next).to eq(
|
156
|
-
expect(list.next).to eq(
|
157
|
-
expect(list.next).to eq(
|
155
|
+
expect(list.next).to eq(20)
|
156
|
+
expect(list.next).to eq(30)
|
157
|
+
expect(list.next).to eq(40)
|
158
158
|
end
|
159
159
|
it "#prev after first returns first value repeatably. " do
|
160
160
|
expect(list.first).to eq(10)
|
@@ -18,7 +18,15 @@ RSpec.describe SknUtils::Lists::LinkedList, "Singular LinkedList " do
|
|
18
18
|
end
|
19
19
|
it "can be initialized with one or more initial values" do
|
20
20
|
list = described_class.new(10,100,100)
|
21
|
-
expect(list.current).to eq(
|
21
|
+
expect(list.current).to eq(10)
|
22
|
+
end
|
23
|
+
it "can be initialized with multiple values" do
|
24
|
+
list = described_class.new(10, 100, 1000)
|
25
|
+
expect(list.current).to eq(10)
|
26
|
+
end
|
27
|
+
it "can not be initialized with any array as the value." do
|
28
|
+
list = described_class.new([10, 100, 1000])
|
29
|
+
expect(list.current).to eq([10, 100, 1000])
|
22
30
|
end
|
23
31
|
it "is initially empty?" do
|
24
32
|
expect(subject.empty?).to be true
|
@@ -36,7 +44,7 @@ RSpec.describe SknUtils::Lists::LinkedList, "Singular LinkedList " do
|
|
36
44
|
expect(list.next).to eq(20)
|
37
45
|
end
|
38
46
|
it "#current returns the last value as a side-effect of initialization via new" do
|
39
|
-
expect(list.current).to eq(
|
47
|
+
expect(list.current).to eq(10)
|
40
48
|
end
|
41
49
|
it "#last returns the last value" do
|
42
50
|
expect(list.last).to eq(100)
|
@@ -116,13 +124,13 @@ RSpec.describe SknUtils::Lists::LinkedList, "Singular LinkedList " do
|
|
116
124
|
let(:list) { described_class.new(10,20, 30, 40, 50, 60, 70, 80, 90, 100) }
|
117
125
|
|
118
126
|
it "#at_index(-999) fails and returns the current element. " do
|
119
|
-
expect(list.at_index(-999)).to eq(
|
127
|
+
expect(list.at_index(-999)).to eq(10)
|
120
128
|
end
|
121
129
|
it "#at_index(0) fails and returns the current element. " do
|
122
|
-
expect(list.at_index(0)).to eq(
|
130
|
+
expect(list.at_index(0)).to eq(10)
|
123
131
|
end
|
124
132
|
it "#at_index(999) fails and returns the current element. " do
|
125
|
-
expect(list.at_index(999)).to eq(
|
133
|
+
expect(list.at_index(999)).to eq(10)
|
126
134
|
end
|
127
135
|
it "#at_index(n) returns the proper element. " do
|
128
136
|
expect(list.at_index(1)).to eq(10)
|
@@ -136,22 +144,22 @@ RSpec.describe SknUtils::Lists::LinkedList, "Singular LinkedList " do
|
|
136
144
|
expect(only.at_index(-10)).to eq(55)
|
137
145
|
end
|
138
146
|
|
139
|
-
it "#nth(-999) returns
|
140
|
-
expect(list.nth(-999)).to eq(
|
147
|
+
it "#nth(-999) returns first value because backward movement is not supported" do
|
148
|
+
expect(list.nth(-999)).to eq(10)
|
141
149
|
end
|
142
150
|
it "#nth(0) returns current value, or last initialization value." do
|
143
|
-
expect(list.nth(0)).to eq(
|
151
|
+
expect(list.nth(0)).to eq(10)
|
144
152
|
end
|
145
153
|
it "#nth(999) returns last initialization value." do
|
146
154
|
expect(list.nth(999)).to eq(100)
|
147
155
|
end
|
148
156
|
it "#current equals last initialization value." do
|
149
|
-
expect(list.current).to eq(
|
157
|
+
expect(list.current).to eq(10)
|
150
158
|
end
|
151
|
-
it "#next after initialization
|
152
|
-
expect(list.next).to eq(
|
153
|
-
expect(list.next).to eq(
|
154
|
-
expect(list.next).to eq(
|
159
|
+
it "#next after initialization returns proper order. " do
|
160
|
+
expect(list.next).to eq(20)
|
161
|
+
expect(list.next).to eq(30)
|
162
|
+
expect(list.next).to eq(40)
|
155
163
|
end
|
156
164
|
it "#first, #next, #current, #prev, #nth, and #last return same value after initialization with one value. " do
|
157
165
|
only = described_class.new(55)
|