Skip to content

Commit

Permalink
updated depricated hashable values to hash into methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mick31 committed Mar 27, 2020
1 parent c22182f commit 510f3da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 4 additions & 6 deletions Graph/Graph/Edge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ extension Edge: CustomStringConvertible {

extension Edge: Hashable {

public var hashValue: Int {
var string = "\(from.description)\(to.description)"
if weight != nil {
string.append("\(weight!)")
}
return string.hashValue
public func hash(into hasher: inout Hasher) {
hasher.combine(from.description)
hasher.combine(to.description)
hasher.combine(weight)
}
}

Expand Down
5 changes: 3 additions & 2 deletions Graph/Graph/Vertex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ extension Vertex: CustomStringConvertible {

extension Vertex: Hashable {

public var hashValue: Int {
return "\(data)\(index)".hashValue
public func hash(into hasher: inout Hasher) {
hasher.combine(data)
hasher.combine(index)
}

}
Expand Down

0 comments on commit 510f3da

Please sign in to comment.