>
> For me the sole specification is that a Bag unlike a Set can hold
> several equal elements.
> The fact that it can count them fast rather than enumerating the whole
> collection is an implementation detail (an important detail of  
> course).

exact this is why for me a dictionary is more like a set than a bag  
because
I can only have one key for #a for example.
This is why I did not totally understand your bag relationships.

>>> a) multiple values can be in the dictionary:
>>>    (Dictionary new) at: 'one' put: 1; at: 'first' put: 1; yourself.
>>
>> For me to be bag would mean more
>>
>>> dc := (DictionaryBag new) at: 'one' put: 1; at: 'one' put: 2;
>>> yourself.
>>   dc at: one
>>    -> #(1 2)
>>
>> Stef
>>
>
> a DictionaryOfBags ?

No I mean if you want to see Dictionary as a bag then
it means that you could have multiple similar keys 'one' in the above  
example.
For a Dictionary (as for now and which I see as a set)
you get only one value for the key 'one'


>
>
> One thing Dictionary is not : a Bag of associations.
> Think of it as a Bag of values.
> As long as you don't override a key, a Dictionary behaves like a Bag:
>
> digits := 0 to: 9.
> b := Bag new.
> d := Dictionary new.
> digits do: [:i | b add: i//2].
> digits do: [:i | d at: i printString put: i//2].
> digits do: [:i |
>   self assert:  (b occurrencesOf: i) = (d occurrencesOf: i)].
>
> Personnally, I would expect
>    d values.
> to answer a Bag (unordered) rather than an Array (arbitrary order)...
> The only advantage of an Array is that it is faster than a  Bag...
>
>
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>


_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to