Philosophical questions about collections

Diego Gomez Deck DiegoGomezDeck at ConsultAr.com
Fri Jun 29 14:38:53 UTC 2001


>Diego,
>
>On Fri, 29 Jun 2001 09:51:00 -0300 Diego Gomez Deck <DiegoGomezDeck at ConsultAr.com> wrote:
>>I can't find the correct way to think about #= message for collections...
>
>You are not alone in this feeling. ;-)
>
>>For example, Dictionary use Set>>= that ignores keys.
>>
>>Bag, has not implemented the message.
>>
>>All the SequenceableCollection family seems to be good (IMHO).
>>
>>There exists a message that compares the elements of a collection with 
>>another ignoring the collection species?
>
>I don't think so, but you could do something like
>
>	collection1 asSet = collection2 asSet
>or
>	collection1 asArray = collection2 asArray
>
>The fact that these two options could easily produce different results suggests that there may be more than one way to think about collection equality. My inclination would be to write a method that did what I wanted in a particular situation and try to make it clear whether the order of the elements was important or not and whether duplicate elements should affect the result. Other factors, such as the precise way of comparing elements, may also be important.

The other 'criteria' could be the way that the keys get compared.

Example:
d := Dictionary new.
d at:1 put:'A'.
d at:2 put:'B'.
d at:3 put:'C'.

{'A'. 'B'. 'C'} isEqualsTo: d

>
>Cheers,
>Bob
>

Diego Gomez Deck





More information about the Squeak-dev mailing list