<div dir="ltr"><div>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?</div><div><br></div><div>Use case: I want a set of objects that are compared for equality using === rather than ==. This doesn't seem possible today, using Set, without creating some sort of wrapper object.</div><div><br></div><div>This particular case would be analogous to using NSHashTable with NSPointerFunctionsObjectPointerPersonality. (Maybe all I'm asking for is a Swiftier API for NSHashTable — including ArrayLiteralConvertible, using generics instead of UnsafePointer<Void>, etc.)</div><div><br></div><div>Similarly, C++'s <a href="http://en.cppreference.com/w/cpp/container/unordered_map">unordered_map</a> and friends have template parameters specifying the hash function and equality comparator, which use std::hash and == by default.</div><div><br></div><div>(Apologies if this has been discussed already; I haven't seen it.)<br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div>Jacob<br></div></div></div></div>
</div></div>