[Pkg] The Trunk: Collections-ul.922.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Jan 19 12:31:53 UTC 2021
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.922.mcz
==================== Summary ====================
Name: Collections-ul.922
Author: ul
Time: 19 January 2021, 1:28:51.784086 pm
UUID: 7d688371-2966-43d3-9000-3985ae9f6afa
Ancestors: Collections-nice.921
Fix off-by-one errors in OrderedCollection's #removeFirst: and #removeLast:. The argument of those methods can be zero.
=============== Diff against Collections-nice.921 ===============
Item was changed:
----- Method: OrderedCollection>>removeFirst: (in category 'removing') -----
removeFirst: n
"Remove the first n objects into an array."
| lastIndexToRemove result |
+ n < 0 ifTrue: [ self errorNoSuchElement ].
- n < 1 ifTrue: [ self errorNoSuchElement ].
lastIndex < (lastIndexToRemove := firstIndex + n - 1) ifTrue: [ self errorNotEnoughElements ].
result := array copyFrom: firstIndex to: lastIndexToRemove.
array from: firstIndex to: lastIndexToRemove put: nil.
firstIndex := lastIndexToRemove + 1.
^result!
Item was changed:
----- Method: OrderedCollection>>removeLast: (in category 'removing') -----
removeLast: n
"Remove the last n objects into an array with last in last position."
| firstIndexToRemove result |
+ n < 0 ifTrue: [ self errorNoSuchElement ].
- n < 1 ifTrue: [ self errorNoSuchElement ].
(firstIndexToRemove := lastIndex - n + 1) < firstIndex ifTrue: [ self errorNotEnoughElements ].
result := array copyFrom: firstIndexToRemove to: lastIndex.
array from: firstIndexToRemove to: lastIndex put: nil.
lastIndex := firstIndexToRemove - 1.
^result!
More information about the Packages
mailing list