[squeak-dev] The Trunk: Collections-eem.603.mcz
Chris Muller
asqueaker at gmail.com
Wed Feb 4 17:07:01 UTC 2015
isSequenceable is a term that refers to a particular *kind* of
Collection, a sequenceable one.
Therefore, IMO, I am unable to think of any more clear and explicit
way of expressing that than "isKindOf: SequenceableCollection"...
On Tue, Feb 3, 2015 at 8:59 PM, Eliot Miranda <eliot.miranda at gmail.com> wrote:
>
>
> On Tue, Feb 3, 2015 at 12:22 PM, Levente Uzonyi <leves at elte.hu> wrote:
>>
>> On Tue, 3 Feb 2015, commits at source.squeak.org wrote:
>>
>>> Eliot Miranda uploaded a new version of Collections to project The Trunk:
>>> http://source.squeak.org/trunk/Collections-eem.603.mcz
>>>
>>> ==================== Summary ====================
>>>
>>> Name: Collections-eem.603
>>> Author: eem
>>> Time: 3 February 2015, 12:06:59.618 pm
>>> UUID: 6521c82f-d8de-4c07-a754-3bc3a8667746
>>> Ancestors: Collections-mt.602
>>>
>>> Three fewer uses of isKindOf:
>>>
>>> =============== Diff against Collections-mt.602 ===============
>>>
>>> Item was changed:
>>> ----- Method: Dictionary>>= (in category 'comparing') -----
>>> = aDictionary
>>> "Two dictionaries are equal if
>>> (a) they are the same 'kind' of thing.
>>> (b) they have the same set of keys.
>>> (c) for each (common) key, they have the same value"
>>>
>>> self == aDictionary ifTrue: [ ^ true ].
>>> + aDictionary isDictionary ifFalse: [^false].
>>> - (aDictionary isKindOf: Dictionary) ifFalse: [^false].
>>> self size = aDictionary size ifFalse: [^false].
>>> self associationsDo: [:assoc|
>>> (aDictionary at: assoc key ifAbsent: [^false]) = assoc
>>> value
>>> ifFalse: [^false]].
>>> ^true
>>>
>>> !
>>>
>>> Item was changed:
>>> ----- Method: SequenceableCollection>>hasEqualElements: (in category
>>> 'comparing') -----
>>> hasEqualElements: otherCollection
>>> "Answer whether the receiver's size is the same as
>>> otherCollection's
>>> size, and each of the receiver's elements equal the corresponding
>>> element of otherCollection.
>>> This should probably replace the current definition of #= ."
>>>
>>> | size |
>>> + otherCollection isSequenceable ifFalse: [^ false].
>>> - (otherCollection isKindOf: SequenceableCollection) ifFalse: [^
>>> false].
>>
>>
>> This should either include an #isCollection check, or #isSequenceable
>> should be moved up to Object.
>
>
> Oops. Good catch. Which would you do? I favour the latter.
>
>> Levente
>>
>>
>>> (size := self size) = otherCollection size ifFalse: [^ false].
>>> 1 to: size do:
>>> [:index |
>>> (self at: index) = (otherCollection at: index) ifFalse:
>>> [^ false]].
>>> ^ true!
>>>
>>> Item was changed:
>>> ----- Method: String>>subStrings: (in category 'converting') -----
>>> subStrings: separators
>>> "Answer an array containing the substrings in the receiver
>>> separated
>>> by the elements of separators."
>>> | char result sourceStream subString |
>>> #Collectn.
>>> "Changed 2000/04/08 For ANSI <readableString> protocol."
>>> + (separators isString or:[separators allSatisfy: [:element |
>>> element isCharacter]]) ifFalse:
>>> + [^ self error: 'separators must be Characters.'].
>>> - (separators isString or:[separators allSatisfy: [:element |
>>> element isKindOf: Character]])
>>> - ifFalse: [^ self error: 'separators must be
>>> Characters.'].
>>> sourceStream := ReadStream on: self.
>>> result := OrderedCollection new.
>>> subString := String new.
>>> [sourceStream atEnd]
>>> whileFalse:
>>> [char := sourceStream next.
>>> (separators includes: char)
>>> ifTrue: [subString notEmpty
>>> ifTrue:
>>> [result add:
>>> subString copy.
>>> subString :=
>>> String new]]
>>> ifFalse: [subString := subString ,
>>> (String with: char)]].
>>> subString notEmpty ifTrue: [result add: subString copy].
>>> ^ result asArray!
>>>
>>>
>>>
>>
>
>
>
> --
> best,
> Eliot
>
>
>
More information about the Squeak-dev
mailing list
|