Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 73f0092

Browse files
Fixed Hashable Conformance to hash(into:)
1 parent 667d265 commit 73f0092

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

‎Graph/Graph/Edge.swift‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ extension Edge: CustomStringConvertible {
2929

3030
extension Edge: Hashable {
3131

32-
public varhashValue:Int {
33-
varstring="\(from.description)\(to.description)"
34-
if weight !=nil{
35-
string.append("\(weight!)")
36-
}
37-
return string.hashValue
38-
}
32+
public func hash(into hasher:inoutHasher) {
33+
hasher.combine(from)
34+
hasher.combine(to)
35+
ifweight!=nil{
36+
hasher.combine(weight)
37+
}
38+
}
3939
}
4040

4141
public func == <T>(lhs: Edge<T>, rhs: Edge<T>) -> Bool {

‎Graph/Graph/Vertex.swift‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ extension Vertex: CustomStringConvertible {
2424

2525
extension Vertex: Hashable {
2626

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

3133
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /