[swift-evolution] Custom equality/hash for Sets

Dmitri Gribenko gribozavr at gmail.com
Thu Feb 18 22:39:02 CST 2016


On Thu, Feb 18, 2016 at 2:58 PM, Jacob Bandes-Storch via
swift-evolution <swift-evolution at swift.org> wrote:
> Would it make sense for the standard library Set to provide variants (or
> parallel versions of the same data structure) that take custom hashValue/==
> implementations at init time (functions taking in Elements), rather than
> relying on Hashable/Comparable protocols?

It might make sense, but we should keep in mind that doing this will
prevent inlining of hashValue/== in most cases.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the swift-evolution mailing list