Re: [SOLVED] Why doesn't CFDictionaryContainsKey() work?
Re: [SOLVED] Why doesn't CFDictionaryContainsKey() work?
- Subject: Re: [SOLVED] Why doesn't CFDictionaryContainsKey() work?
- From: David Duncan <email@hidden>
- Date: Thu, 16 Nov 2006 09:34:53 -0800
On Nov 16, 2006, at 9:25 AM, Alan Smith wrote:
I would not say that useing CFDictionaryContainsKey() is a zillion
times slower unless you have tested and can show me statistics that
prove it.
I understand NSDictionary just fine, thank you. I don't want the
object at the key, I want to make sure it exists.
He's not saying that CFDictionaryContainsKey() is slower, he's saying
that [[self allKeys] containsObject: key] is slower. When you do that
you
1) Create an array of all the keys in the CFDictionary -- O(n)
2) Search that array for your key -- O(n)
When you call CFDictionaryContainsKey() or ([self objectForKey:key] !
= nil) you are performing a single O(lg n) or O(1) operation, which
is faster than performing 2 O(n) operations.
--
David Duncan
Apple DTS Quartz and Printing
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden