Skip to content

Commit e21f966

Browse files
committed
Fix: refine equality and hash methods based on review
1 parent 0ac1cc6 commit e21f966

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

src/Containers-Queue-Tests/CTQueueTest.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ CTQueueTest >> testEquality [
305305
q1 enqueue: 'A'; enqueue: 'B'.
306306
q2 enqueue: 'A'; enqueue: 'B'.
307307

308-
self assert: q1 equals: q2.
308+
self assert: q1 = q2.
309309
self assert: q1 hash equals: q2 hash.
310310
]
311311

src/Containers-Queue/CTQueue.class.st

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ CTQueue class >> new: anInteger [
3838
CTQueue >> = anObject [
3939

4040
self class = anObject class ifFalse: [ ^ false ].
41-
self == anObject ifTrue: [ ^ true ].
4241
self size = anObject size ifFalse: [ ^ false ].
4342

44-
^ self asArray = anObject asArray
43+
^ self elements = anObject elements
4544
]
4645

4746
{ #category : 'converting' }
@@ -105,6 +104,12 @@ CTQueue >> do: aBlock [
105104
]
106105
]
107106

107+
{ #category : 'accessing' }
108+
CTQueue >> elements [
109+
110+
^ elements
111+
]
112+
108113
{ #category : 'adding' }
109114
CTQueue >> enqueue: anObject [
110115

@@ -161,10 +166,11 @@ CTQueue >> grow [
161166

162167
{ #category : 'comparing' }
163168
CTQueue >> hash [
164-
165169
| hashValue |
166-
hashValue := self species hash.
167-
self do: [ :each | hashValue := (hashValue + each hash) hashMultiply ].
170+
hashValue := 131.
171+
self do: [ :each |
172+
hashValue := (hashValue + each hash) hashMultiply
173+
].
168174
^ hashValue
169175
]
170176

0 commit comments

Comments
 (0)