Files
swift-collections/Sources/PersistentCollections/_HashValue.swift
T
Karoy Lorentey 14f90620c8 [PersistentCollections] Introduce _Bucket, _Bitmap, _HashPath, and _HashValue
These provide nicer tools for slicing up hash values and dealing with node bitmaps.

_Bucket is a logical entry in the hash table inside a node.
_Bitmap is a set of bucket values, represented by a bitset.
_HashPath facilitates slicing up a hash value into a series of bucket values.
_HashValue represents a hash value.

This is still just mostly superficial refactoring, with little to no functional changes.
2022-09-09 00:47:10 -07:00

28 lines
841 B
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Collections open source project
//
// Copyright (c) 2022 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//
/// An abstract representation of a hash value.
internal struct _HashValue {
internal var value: UInt
internal init<Key: Hashable>(_ key: Key) {
let hashValue = key._rawHashValue(seed: 0)
self.value = UInt(bitPattern: hashValue)
}
}
extension _HashValue: Equatable {
@inline(__always)
internal static func ==(left: Self, right: Self) -> Bool {
left.value == right.value
}
}