The Trunk: Collections-nice.370.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-nice.370.mcz

commits-2
Nicolas Cellier uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-nice.370.mcz

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

Name: Collections-nice.370
Author: nice
Time: 21 August 2010, 4:21:21.554 pm
UUID: fa914463-6f11-482d-9735-887957d45552
Ancestors: Collections-eem.369

Fix http://bugs.squeak.org/view.php?id=6943
Heap equality should be transitive.

A Heap won't equal an Array anymore, but I very much doubt this feature ever was of any use.
Raise your voice if you don't agree.

#collect: use collect:as: and answer an Array, like before
#select: uses copyEmpty strategy and now answers another Heap with same sortBlock

=============== Diff against Collections-eem.369 ===============

Item was added:
+ ----- Method: Heap>>collect: (in category 'enumerating') -----
+ collect: aBlock
+ ^self collect: aBlock as: Array!

Item was added:
+ ----- Method: Heap>>select: (in category 'enumerating') -----
+ select: aBlock
+ "Evaluate aBlock with each of my elements as the argument. Collect into
+ a new collection like the receiver, only those elements for which aBlock
+ evaluates to true."
+
+ | newCollection |
+ newCollection := self copyEmpty.
+ self do:
+ [:each |
+ (aBlock value: each)
+ ifTrue: [newCollection add: each]].
+ ^ newCollection!

Item was added:
+ ----- Method: Heap>>copyEmpty (in category 'copying') -----
+ copyEmpty
+ "Answer a copy of the receiver without any of the receiver's elements."
+
+ ^self class sortBlock: sortBlock!

Item was removed:
- ----- Method: Heap>>species (in category 'private') -----
- species
- ^ Array!