• 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: Fast hash of NSData?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fast hash of NSData?


  • Subject: Re: Fast hash of NSData?
  • From: Kyle Sluder <email@hidden>
  • Date: Fri, 29 Nov 2013 12:36:30 -0800

> On Nov 29, 2013, at 11:58 AM, Graham Cox <email@hidden> wrote:

>
> Another general question.
>
> Does anyone have a quick-and-dirty (but functional) way to hash NSData? I’m currently using SHA-1 but it’s quite slow. All I need is a way to determine whether one block of data is identical to another or not - but every bit counts.

Just for the sake of the list, though I'm certain you're aware of this yourself: you can't use a hash function to check for equality unless it is a perfect hash function. You can use it to reduce the number of comparisons per candidate, but you'll always wind up doing at least O(M+N) comparisons (where M is the size of your input and N is the length of your hash output).

Often, it's better to improve the data structure before trying a different hash function. It's much easier to reason about how to improve a solution in terms of algorithm analysis of your data structure rather than it is to perform an empirical analysis of a specific hash function's collision-to-speed tradeoffs.

Long way of saying: what's the actual problem you're trying to solve? Maybe a hash table is a poor fit.

--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: Fast hash of NSData?
      • From: Graham Cox <email@hidden>
    • Re: Fast hash of NSData?
      • From: Tito Ciuro <email@hidden>
References: 
 >Fast hash of NSData? (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Fast hash of NSData?
  • Next by Date: Re: Fast hash of NSData?
  • Previous by thread: Re: Fast hash of NSData?
  • Next by thread: Re: Fast hash of NSData?
  • Index(es):
    • Date
    • Thread