[Newbies] Re: Another extension proposal -> subsets

cdrick cdrick65 at gmail.com
Fri Jul 25 17:07:01 UTC 2008

really interesting.
but it reveals slower but it was because of Set operations. To be consistent
with other method, I used an array.

  | subsetsSize subsets workArray |
  workArray := self asArray.
  subsetsSize := 2 raisedTo: self size.
  subsets := Array new: subsetsSize.
  1 to: subsetsSize do: [:sift |
     subsets at: sift put:
       (workArray selectIntegerMask: sift into: (Set new: sift highBit) )].

Putting asSet as the end is very expensive when the collection is big


set := (1 to: 15) asSet.
[ set subsets "first sift" ] timeToRun ." 2484"
[ set subsets4  "combinationsSize:do:"] timeToRun. " 1598"
[ set subsets5  "Zulk"] timeToRun." 12493"    "I think he uses Set for the
[ set subsets6  "optimized sift] timeToRun. " 1436"   "Winner :) "

Thats was instructive, especially the way you deal with bit. Nice also how
you removed the reverse(s).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20080725/ce3d9125/attachment.htm

More information about the Beginners mailing list