On Tue, 19 Feb 2008 02:35:34 +0100, Marcin Tustin wrote:

Isn't Cedrick's aida solution going to be significantly faster?

No, solutions based on #become: are the slowest possible. The VM has to sweep the whole memory, for all variables in the system, to find all references during #become:, like this

 | oop |
 oop := self someObject.
 ["check+replace reference in variables of oop, then"
  oop := oop nextObject.
  oop = 0
  ] whileFalse.

Now think that you (and every other user of your software ;-) have an .image with 2-4gigs every time you use #become: ...

If you want something faster, look at Bert's

 myCollection removeAllSuchThat: [:each | true]

and try to make it faster but keep still it correct (old elements must be nil'ed).

/Klaus

On Feb 19, 2008 1:02 AM, Ron Teitelbaum <[EMAIL PROTECTED]> wrote:

Hi Sophie,

aCollection copy do: [:anElement |
       aCollection remove: anElement
].

Why copy? If you start removing items from the collection, increasing the
index will cause you to skip elements.

Ron

> -----Original Message-----
> From: itsme213
>
> I want to clear its contents (size goes back to zero), and can't seem to
> find something like #clear or #empty. Cannot use a new collection as
there
> are shared references to it.
>
> Thanks - Sophie


_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to