[squeak-dev] removing from a collection while enumerating it

Ron Teitelbaum ron at usmedrec.com
Fri Jul 5 13:56:37 UTC 2013


Hi Chris,

Just a suggestion but something to think about.  If your collections are too big then maybe you could find a way to segment the data and move the items into a tree structure.  This would solve most of your problems with copying and performance.

All the best,

Ron Teitelbaum 


> From:  Chris Muller
> To: squeak dev
> Subject: [squeak-dev] removing from a collection while enumerating it
> 
> I have a case where I need to remove certain entries from an OrderedCollection
> that will be called very frequently.  I therefore want to avoid copying the
> collection (to safely remove while
> enumerating) but it seems #reverseDo: can do what I want.
> 
>   myCollection reverseDo: [ : each | each meetsSomeCriteria ifTrue: [
> myCollection remove: each ] ]
> 
> Does anyone see any problem with doing this?
> 




More information about the Squeak-dev mailing list