On 9/18/08, Yoshiki Ohshima yoshiki@vpri.org wrote:
At Thu, 18 Sep 2008 10:00:15 +0100, Marcin Tustin wrote:
Would this be O(n^2) to remove all nils?
Not in a way it matters. OrderedCollection moves items not eagarly.
Do you mean that it will do a lazy delete?
In any case, if this is a conveyor belt, then you should almost certainly be using a linke data structure, and iterate
over the structure to delete the unwanted links.
No in two reasons; 1) he wasn't talking about removing items in the middle
Look at the original example.
and 2) OrderedCollection is usually more efficient than the
naive LinkedList, as less dereferencing. (And, it could get more benefits from using array manipulation primitives like replaceFrom:to:, but it can't at least for addFirst:.)
I think this would be an empirical question.
-- Yoshiki
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Am 18.09.2008 um 11:38 schrieb Marcin Tustin:
On 9/18/08, Yoshiki Ohshima yoshiki@vpri.org wrote: At Thu, 18 Sep 2008 10:00:15 +0100, Marcin Tustin wrote:
Would this be O(n^2) to remove all nils?
Not in a way it matters. OrderedCollection moves items not eagarly.
Do you mean that it will do a lazy delete?
#removeFirst just nils out the first slot and moves the start index.
Compaction only happens when adding elements and there is space at the beginning.
- Bert -
At Thu, 18 Sep 2008 10:38:52 +0100, Marcin Tustin wrote:
No in two reasons; 1) he wasn't talking about removing items in the middle
Look at the original example.
Right. But still I think suggesting to use LinkedList here is not a good idea.
and 2) OrderedCollection is usually more efficient than the naive LinkedList, as less dereferencing. (And, it could get more benefits from using array manipulation primitives like replaceFrom:to:, but it can't at least for addFirst:.)
I think this would be an empirical question.
Exacly. Measure the performance before suggesting a complex solution.
-- Yoshiki
beginners@lists.squeakfoundation.org