Protocols
The following protocols are available globally.
-
A variant of
Hashable
that makes it simpler to generate good hash values.Instead of
hashValue
, you need to implementaddHashes
, adding data that should contribute to the hash to the supplied hasher. The hasher takes care of blending the supplied data together.Example implementation:
See morestruct Book: SipHashable { var title: String var pageCount: Int func appendHashes(to hasher: inout SipHasher) { hasher.append(title) hasher.append(pageCount) } static func ==(left: Book, right: Book) -> Bool { return left.title == right.title && left.pageCount == right.pageCount } }
Declaration
Swift
public protocol SipHashable: Hashable