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 implement addHashes, adding data that should contribute to the hash to the supplied hasher. The hasher takes care of blending the supplied data together.

    Example implementation:

    struct 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
        }
    }
    
    See more

    Declaration

    Swift

    public protocol SipHashable: Hashable