On Aug 7, 2011, at 23:09 , Kevin Bracey wrote:

> My question is would it be more efficient to sort the array so the next 
> action becomes the Last object of the array and remove it from the top 
> instead of the bottom?
> 
> Or is this all so efficient it make no real difference.

It's not a question so much of efficiency as noticeability -- almost certainly 
the difference isn't going to be noticeable by any practical standard.

However, since you have an (apparently) arbitrary choice between sorting the 
"next" operation to the start or the end of the array, put it at the end. It's 
not hard to imagine that the implementation would shuffle elements down if you 
remove the first, so you may as well assume that's what happens.

Putting the "next" operation at the end also has the very small beneficial 
side-effect of letting you use 'lastObject' to get it, which (unlike 
'objectAtIndex:0') doesn't crash if the array is empty. Thus, the source code 
is probably conciser and clearer, all other things being equal.


_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to