The Trunk: Collections-ul.346.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-ul.346.mcz

commits-2
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.346.mcz

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

Name: Collections-ul.346
Author: ul
Time: 22 March 2010, 5:29:48.92 pm
UUID: 4354e2d0-eb5a-184b-b0bd-3a8e5b591d2a
Ancestors: Collections-ul.344

- added #sorted protocol to collections
- added two helpful comments to discourage the use of #asSortedCollection*

=============== Diff against Collections-ul.344 ===============

Item was changed:
  ----- Method: Collection>>asSortedCollection (in category 'converting') -----
  asSortedCollection
  "Answer a SortedCollection whose elements are the elements of the
+ receiver. The sort order is the default less than or equal.
+ Use #sorted: if you don't really need a SortedCollection, but a sorted collection!!"
+
+ ^self as: SortedCollection!
- receiver. The sort order is the default less than or equal."
-
- ^ self as: SortedCollection!

Item was added:
+ ----- Method: OrderedCollection>>sorted: (in category 'sorting') -----
+ sorted: aSortBlockOrNil
+ "Return a new sequenceable collection which contains the same elements as self but its elements are sorted by aSortBlockOrNil. The block should take two arguments and return true if the first element should preceed the second one. If aSortBlock is nil then <= is used for comparison."
+
+ ^self copy sort: aSortBlockOrNil!

Item was changed:
  ----- Method: Collection>>asSortedCollection: (in category 'converting') -----
  asSortedCollection: aSortBlock
  "Answer a SortedCollection whose elements are the elements of the
+ receiver. The sort order is defined by the argument, aSortBlock.
+ Use #sorted: if you don't really need a SortedCollection, but a sorted collection!!"
- receiver. The sort order is defined by the argument, aSortBlock."
 
  | aSortedCollection |
  aSortedCollection := SortedCollection new: self size.
  aSortedCollection sortBlock: aSortBlock.
  aSortedCollection addAll: self.
  ^ aSortedCollection!

Item was added:
+ ----- Method: Collection>>sorted: (in category 'sorting') -----
+ sorted: aSortBlockOrNil
+ "Return a new sequenceable collection which contains the same elements as self but its elements are sorted by aSortBlockOrNil. The block should take two arguments and return true if the first element should preceed the second one. If aSortBlock is nil then <= is used for comparison."
+
+ ^self asArray sort: aSortBlockOrNil!

Item was added:
+ ----- Method: Collection>>sorted (in category 'sorting') -----
+ sorted
+ "Return a new sequenceable collection which contains the same elements as self but its elements are sorted in ascending order using the #'<=' operator."
+
+ ^self sorted: nil!

Item was added:
+ ----- Method: Array>>sorted: (in category 'sorting') -----
+ sorted: aSortBlockOrNil
+ "Return a new sequenceable collection which contains the same elements as self but its elements are sorted by aSortBlockOrNil. The block should take two arguments and return true if the first element should preceed the second one. If aSortBlock is nil then <= is used for comparison."
+
+ ^self copy sort: aSortBlockOrNil!