On Mon, 28 Dec 2009, Stéphane Ducasse wrote:
Levente you should realize that these methods have been defined and used
more than a couple of years ago.
Most of the methods I suggested were added to squeak long before they
started working on the project.
They are used by a cool group of programmer and the infrastructure of Moose
since
also a couple of years so I would not call them useless misleading
I guess I missed a comma here, I meant useless or misleading.
but thanks for you analysis :)
It is time to rewrite them.
But flatCollect: and flatCollectAsSet: names are more important than their
implementation.
I just checked these and most of them are useless misleading or duplicate, like:
Collection >>
#collectAsSet: -> #collect:as: (ok, it's new in pharo)
#equalsTo:
misleading name, #containsSameElementsAs: would be better IMO
#(1 1 2) equalsTo: #(2 1 1) ===> true
Yes I do not really like it
#flatCollect: -> #gather:
the problem is that gather: does not convey its intention.
flatCollect: is much much better.
#flatCollectAsSet: -> #gather: + #asSet
Is it not faster?
I don't think that growing a Set is faster than growing an Array, then
converting it to a Set, but let's see the numbers:
"Prepare an array with 10000 elements, each element is an array with one
integer. 10% is duplicate."
data := (1 to: 9000) collect: [ :each | { SmallInteger maxVal atRandom }
].
data := data, (data last: 1000).
data := data shuffled.
(1 to: 10) collect: [ :run |
[ (data gather: [ :each | each ]) asSet ] timeToRun ]. ===> #(14 15 14
15 14 14 15 14 15 14).
(1 to: 10) collect: [ :run |
[ data flatCollectAsSet: [ :each | each ] ] timeToRun ]. ===> #(29 29
29 28 29 28 28 29 29 29)
Levente
#flatten --
misleading name, since it doesn't change the object, but returns
a new array and it's only flattening one level which is what #gather:
does. Tthere's a proper #flattened implementation in squeak treated
inbox if you're interested. (guess why it's not in the trunk)
#groupBy: -> #groupBy:having:
#sum: -> #detectSum:
Symbol >>
#value (same as super)
SequenceableCollection >>
#shuffle -> #shuffled
OrderedCollection >>
#removeAtIndex: -> #removeAt:
(-> means that the extension on the left is the same as or worse than
the already existing method(s) on the right)
I guess you should shrink this package. :)
Levente_______________________________________________
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
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project