Re: Where is NSList?
Re: Where is NSList?
- Subject: Re: Where is NSList?
- From: Chris Hanson <email@hidden>
- Date: Wed, 28 Jul 2004 12:18:30 -0700
On Jul 28, 2004, at 2:48 AM, Pandaa wrote:
ToThere is no NSLinkedList. What would the point of such an object
be? There's already one ordered collection, NSArray.
Ordered and indexed. A list is ordered and non-indexed. An array has
O(n) insert and remove and O(1) indexed random access. A list has O(1)
insert and remove and O(n) indexed random access.
Actually, any ordered collection should also be indexable. That's what
ordering gets you. A List is-a OrderedCollection and an Array is-a
OrderedCollection. The only difference is in their performance
characteristics for insert, remove, and random access.
I'd suggest using NSArray/NSMutableArray for ordered collections, and
only worrying about their access characteristics if use and profiling
of your application point to them as a performance issue.
This is a *very* naive view which may well lead to O(n^2) or worse
implementations of O(1) problems!
Actually, it's a pragmatic view. Don't spend your time optimizing
something until you actually know it needs to be optimized. That use
of a list instead of an array for some small piece might not make as
much difference to the performance of your application as using OpenGL
will (for example).
-- Chris
_______________________________________________
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.