Set hasing algorithm