[Newbies] Iterating and removing items from OrderedCollections

Bert Freudenberg bert at freudenbergs.de
Thu Sep 18 09:30:20 UTC 2008


Am 18.09.2008 um 11:00 schrieb Marcin Tustin:

> Would this be O(n^2) to remove all nils?

This only removes nils from the start. If n is the size of the  
collection and m the number of nils at its beginning then it's only  
O(m).

>        start := coll findFirst: [:each | each ~~ nil].
>        coll removeFirst: start-1.

- Bert -



More information about the Beginners mailing list