Skip to content

Commit 2c47dc3

Browse files
authored
Merge pull request #922 from mick31/graph/update_depricated_hash_values
updated depricated hashable values to hash into methods
2 parents c22182f + 510f3da commit 2c47dc3

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

Graph/Graph/Edge.swift

+4-6
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ extension Edge: CustomStringConvertible {
2929

3030
extension Edge: Hashable {
3131

32-
public var hashValue: Int {
33-
var string = "\(from.description)\(to.description)"
34-
if weight != nil {
35-
string.append("\(weight!)")
36-
}
37-
return string.hashValue
32+
public func hash(into hasher: inout Hasher) {
33+
hasher.combine(from.description)
34+
hasher.combine(to.description)
35+
hasher.combine(weight)
3836
}
3937
}
4038

Graph/Graph/Vertex.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ extension Vertex: CustomStringConvertible {
2424

2525
extension Vertex: Hashable {
2626

27-
public var hashValue: Int {
28-
return "\(data)\(index)".hashValue
27+
public func hash(into hasher: inout Hasher) {
28+
hasher.combine(data)
29+
hasher.combine(index)
2930
}
3031

3132
}

0 commit comments

Comments
 (0)