• 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: NSMapTable with C strings as keys
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMapTable with C strings as keys


  • Subject: Re: NSMapTable with C strings as keys
  • From: Kyle Sluder <email@hidden>
  • Date: Tue, 28 May 2013 07:59:12 -0700

On May 28, 2013, at 12:38 AM, Oleg Krupnov <email@hidden> wrote:

> I just made the following experiment:
>
> I specified a hash method for my NSMapTable, but it always returns 0.
> This seems to force the NSMapGet to always use key comparison for
> searching for elements, as hash is always "not unique".
>
> Is this a good idea?

If you're going to do that, why bother with an NSMapTable at all? Just store your pointers in a C array.

>
> Let me think. The keys are quite short strings, like 5-10 chars.

How about making your hash function just return the first character casted to int?

>
> If we take the expense of calculating hash once for each search, then
> comparing hash values is very quick, plus a few string comparisons in
> the end if hash is not unique

It's not useful to pursue this line of thinking without benchmarks.

--Kyle Sluder

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSMapTable with C strings as keys
      • From: Oleg Krupnov <email@hidden>
References: 
 >NSMapTable with C strings as keys (From: Oleg Krupnov <email@hidden>)
 >Re: NSMapTable with C strings as keys (From: Jens Alfke <email@hidden>)
 >Re: NSMapTable with C strings as keys (From: Oleg Krupnov <email@hidden>)
 >Re: NSMapTable with C strings as keys (From: Jean-Daniel Dupas <email@hidden>)
 >Re: NSMapTable with C strings as keys (From: Oleg Krupnov <email@hidden>)

  • Prev by Date: Re: rate limiting calls
  • Next by Date: Re: rate limiting calls
  • Previous by thread: Re: NSMapTable with C strings as keys
  • Next by thread: Re: NSMapTable with C strings as keys
  • Index(es):
    • Date
    • Thread