• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [SOLVED] Why doesn't CFDictionaryContainsKey() work?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Re: [SOLVED] Why doesn't CFDictionaryContainsKey() work?
      • From: "Alan Smith" <email@hidden>
References: 
 >Why doesn't CFDictionaryContainsKey() work? (From: "Alan Smith" <email@hidden>)
 >Re: Why doesn't CFDictionaryContainsKey() work? (From: AurĂ©lien HugelĂ© <email@hidden>)
 >[SOLVED] Why doesn't CFDictionaryContainsKey() work? (From: "Alan Smith" <email@hidden>)

  • Prev by Date: Tooltips for hidden applications
  • Next by Date: New bindings for NSArrayController
  • Previous by thread: [SOLVED] Why doesn't CFDictionaryContainsKey() work?
  • Next by thread: Re: Re: [SOLVED] Why doesn't CFDictionaryContainsKey() work?
  • Index(es):
    • Date
    • Thread