[squeak-dev] The Trunk: Collections-mt.968.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Dec 9 13:07:00 UTC 2021


Marcel Taeumel uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-mt.968.mcz

==================== Summary ====================

Name: Collections-mt.968
Author: mt
Time: 9 December 2021, 2:06:57.821766 pm
UUID: a9955bd5-38b0-7e45-8b90-46a39ae0ba9a
Ancestors: Collections-mt.967, Collections-ct.957, Collections-ct.958, Collections-ul.960

Merge. Note that I think that #withKeysSorted: is okay, yet, my first thought was whether this should rather read #copyWithKeysSorted:. Then again, there are a lot of #with* and #without* methods on String etc. already. And "sorted" implies a copy, compared to (in-place) "sort".

Collections-ct.957:
	Adds Collection >> #sortedSafely analogously to Dictionary >> #keysSortedSafely. This can establish an order for arbitrary kinds of elements.

Collections-ct.958:
	Adds Dictionary >> #withKeysSorted: and Dictionary >> #withKeysSortedSafely. Requires Collections-ct.957.

Collections-ul.960:
	Removed the private method with no senders: Dictionary>>valueAtNewKey:put:atIndex:declareFrom:.

=============== Diff against Collections-mt.967 ===============

Item was added:
+ ----- Method: Collection>>sortedSafely (in category 'sorting') -----
+ sortedSafely
+ 	"A variation of #sorted that uses #compareSafely: instead of #<= to compare its elements. Thus, collections of arbitrary objects can be sorted, which usually involves an object's #printString. See implementors of #compareSafely:."
+ 	
+ 	^ self sorted: [:x :y | x compareSafely: y]!

Item was changed:
  ----- Method: Dictionary>>keysSortedSafely (in category 'accessing') -----
  keysSortedSafely
+ 
+ 	^ self keys sortedSafely!
- 	"Answer a sorted Array containing the receiver's keys."
- 	^ self keys sort:
- 		[ : x : y | x compareSafely: y ]!

Item was added:
+ ----- Method: Dictionary>>withKeysSorted: (in category 'sorting') -----
+ withKeysSorted: aSortBlockOrNil
+ 
+ 	| sorted |
+ 	sorted := OrderedDictionary new: self size.
+ 	(self keys sorted: aSortBlockOrNil) do: [:key |
+ 		sorted at: key put: (self at: key)].
+ 	^ sorted!

Item was added:
+ ----- Method: Dictionary>>withKeysSortedSafely (in category 'sorting') -----
+ withKeysSortedSafely
+ 
+ 	| sorted |
+ 	sorted := OrderedDictionary new: self size.
+ 	self keysSortedSafely do: [:key | sorted at: key put: (self at: key)].
+ 	^ sorted!



More information about the Squeak-dev mailing list