Re: Cocoa semantics
Re: Cocoa semantics
- Subject: Re: Cocoa semantics
- From: Allan Odgaard <email@hidden>
- Date: Sat, 17 Jul 2004 21:24:08 +0200
On 16. Jul 2004, at 21:00, Tom Davie wrote:
[...] The conclusion I have come to is that a class operator similar
to cons should be provided, but should in fact copy the old list
No, that has awful performance. Copying the list will be linear, and
will be required each time you add an element, so creating a list of
1,000 elements will cause approximately 500,000 "nodes" to be copied.
What you should probably do is to provide the linked list as one
container class and not see it as individual nodes being concatenated.
This container has state and you can add/remove nodes from the
container, which change the internal state of the object, similar to
how you loose the previous state in FP you also do loose it in OO.
But why are you writing a linked list class? normally lists are good
because you can add /remove items in constant time, but if you do the
copy and you provide functions like removeObjectAtIndex:, then you do
not get any performance advantages, on the contrary...
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.