Marcel Taeumel uploaded a new version of Collections to project The Trunk: http://source.squeak.org/trunk/Collections-mt.1049.mcz
==================== Summary ====================
Name: Collections-mt.1049 Author: mt Time: 10 August 2023, 9:58:43.81662 am UUID: 7a94c086-e179-1148-899a-139ecbc19f5b Ancestors: Collections-mt.1048
Make #withoutDuplicates available to more kinds of collections. Thanks to Christoph (ct) for the idea. Here is the discussion: http://lists.squeakfoundation.org/archives/list/squeak-dev@lists.squeakfound...
=============== Diff against Collections-dtl.1047 ===============
Item was added: + ----- Method: Bag>>copyWithoutDuplicates (in category 'copying') ----- + copyWithoutDuplicates + "Overwritten for better performance. We already know about the unique items in the receiver." + + ^ self species basicNew + setContents: (contents collect: [:count | 1]); + yourself!
Item was added: + ----- Method: Bitset>>copyWithoutDuplicates (in category 'copying') ----- + copyWithoutDuplicates + + self shouldNotImplement.!
Item was added: + ----- Method: CharacterSet>>copyWithoutDuplicates (in category 'copying') ----- + copyWithoutDuplicates + + self shouldNotImplement.!
Item was added: + ----- Method: Collection>>copyWithoutDuplicates (in category 'copying') ----- + copyWithoutDuplicates + "Answer a copy of the receiver that preserves order, if any, but eliminates any duplicates." + + | seen | + seen := Set new: self size. + ^ self select: [:each | seen ifAbsentAdd: each]!
Item was added: + ----- Method: Collection>>withoutDuplicates (in category 'copying') ----- + withoutDuplicates + "Answer a variant of the receiver that has no duplicate elements. Might be the receiver itself if it already contains no duplicates. See subclass implementations. If you want to modify the result, use #copyWithoutDuplicates to make it explicit." + + ^ self copyWithoutDuplicates!
Item was added: + ----- Method: Dictionary>>copyWithoutDuplicateValues (in category 'copying') ----- + copyWithoutDuplicateValues + + ^ super copyWithoutDuplicates!
Item was added: + ----- Method: Dictionary>>copyWithoutDuplicates (in category 'copying') ----- + copyWithoutDuplicates + "Behaves like a set because keys are already unique. Note that if you want to remove duplicate values, use #values first, then #copyWithoutDuplicates. Or see #copyWithoutDuplicateValues." + + ^ self copy!
Item was added: + ----- Method: Dictionary>>withoutDuplicateValues (in category 'copying') ----- + withoutDuplicateValues + + ^ self copyWithoutDuplicateValues!
Item was added: + ----- Method: Dictionary>>withoutDuplicates (in category 'copying') ----- + withoutDuplicates + "Behaves like a set because keys are already unique. Note that if you want to remove duplicate values, use #values first, then #withoutDuplicates. Or see #withoutDuplicateValues." + + ^ self!
Item was added: + ----- Method: Heap>>copyWithoutDuplicates (in category 'copying') ----- + copyWithoutDuplicates + + self shouldNotImplement.!
Item was added: + ----- Method: Matrix>>copyWithoutDuplicates (in category 'copying') ----- + copyWithoutDuplicates + + self shouldNotImplement.!
Item was removed: - ----- Method: SequenceableCollection>>withoutDuplicates (in category 'copying') ----- - withoutDuplicates - "Answer a copy of the receiver that preserves order but eliminates any duplicates." - | seen | - seen := Set new: self size. - ^self select: [:each| seen ifAbsentAdd: each]!
Item was added: + ----- Method: Set>>copyWithoutDuplicates (in category 'copying') ----- + copyWithoutDuplicates + "Overwritten for better performance. We already know about the unique items in the receiver." + + ^ self copy!
Item was added: + ----- Method: Set>>withoutDuplicates (in category 'copying') ----- + withoutDuplicates + "Overwritten for better performance. We already know about the unique items in the receiver." + + ^ self!
packages@lists.squeakfoundation.org