skn_utils 3.3.0 → 3.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aec86482b36e3dc0625a89641a5220417cbb4761
4
- data.tar.gz: dd1e2519bf5d407deb7c05f1d7454e2b2db2e9e1
3
+ metadata.gz: fb741d6ef4692e94ee1f7649bc655bdac1fcc068
4
+ data.tar.gz: da995ac562de18cea5b4c8950e6ae37349926947
5
5
  SHA512:
6
- metadata.gz: 1f8b4978cd8bdf65eece11e09f400ba65f1b3904fc61e7c6f88889b968a9802cad5155b3bb9dea96ad960f5d147b81bf00ca1a04e742e86fe6863afdafa6ef54
7
- data.tar.gz: f61b021c403bf7dcade30dab45625078e0e8e19c48f41d3f1a73820e7996f48663683a1a16bca40997630ced0bfce38ae57640d4b86b37aff4a703f498a551ed
6
+ metadata.gz: 0c9c7ce7644387a73836ceb91fa9efd184c65e0ad8ca35702be2539d94aff52edaac42b579fa18eb7a858d3283d6fd103c27aabf6210f5d8b2b0419052a9e4c3
7
+ data.tar.gz: 5623acf078e653111cc05a56e5a195758e9ef8908722a71ae3ac8a1ba31340fcbbe204ae9612a8140540863d4765dd4cd21d6b4fc9473ae7ee1c7dd1cf8b5d4f
@@ -13,6 +13,7 @@ module SknUtils
13
13
  @tail = nil
14
14
  @size = 0
15
15
  values.each {|value| insert(value) }
16
+ first if values.size > 1
16
17
  end
17
18
 
18
19
  #
@@ -14,6 +14,7 @@ module SknUtils
14
14
  @tail = nil
15
15
  @size = 0
16
16
  values.each {|value| insert(value) }
17
+ first if values.size > 1
17
18
  end
18
19
 
19
20
  #
@@ -14,6 +14,7 @@ module SknUtils
14
14
  @tail = nil
15
15
  @size = 0
16
16
  values.each {|value| insert(value) }
17
+ first if values.size > 1
17
18
  end
18
19
 
19
20
  #
@@ -3,7 +3,7 @@ module SknUtils
3
3
  class Version
4
4
  MAJOR = 3
5
5
  MINOR = 3
6
- PATCH = 0
6
+ PATCH = 1
7
7
 
8
8
  def self.to_s
9
9
  [MAJOR, MINOR, PATCH].join('.')
@@ -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(100)
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 last value as a side-effect of initialization via new" do
39
- expect(list.current).to eq(100)
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(90)
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(100)
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(100)
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(100)
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) returns wraps to starting place, or last initialization value." do
143
- expect(list.nth(-999)).to eq(100)
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(100)
146
+ expect(list.nth(0)).to eq(10)
147
147
  end
148
- it "#nth(999) returns last initialization value." do
149
- expect(list.nth(999)).to eq(100)
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 last initialization value." do
152
- expect(list.current).to eq(100)
151
+ it "#current equals first initialization value." do
152
+ expect(list.current).to eq(10)
153
153
  end
154
- it "#next after initialization wraps to first initialization value. " do
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(100)
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 last value as a side-effect of initialization via new" do
39
- expect(list.current).to eq(100)
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(90)
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(100)
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(100)
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(100)
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(100)
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 last initialization value." do
152
- expect(list.current).to eq(100)
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(100)
156
- expect(list.next).to eq(100)
157
- expect(list.next).to eq(100)
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(100)
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(100)
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(100)
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(100)
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(100)
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 100 instead of 10 because backward movement is not supported" do
140
- expect(list.nth(-999)).to eq(100)
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(100)
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(100)
157
+ expect(list.current).to eq(10)
150
158
  end
151
- it "#next after initialization equals last initialization value. " do
152
- expect(list.next).to eq(100)
153
- expect(list.next).to eq(100)
154
- expect(list.next).to eq(100)
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skn_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Scott Jr