File tree Expand file tree Collapse file tree 4 files changed +46
-4
lines changed
Expand file tree Collapse file tree 4 files changed +46
-4
lines changed Original file line number Diff line number Diff line change 88public import Foundation
99
1010/// A graphics path is a mathematical description of a series of shapes or lines.
11- public final class CGPath {
12-
11+ public class CGPath : Hashable {
1312 public typealias Element = PathElement
1413
1514 public var elements : [ Element ]
1615
1716 public init ( elements: [ Element ] = [ ] ) {
18-
1917 self . elements = elements
2018 }
19+
20+ public static func == ( lhs: CGPath , rhs: CGPath ) -> Bool {
21+ lhs. elements == rhs. elements
22+ }
23+
24+ public func hash( into hasher: inout Hasher ) {
25+ hasher. combine ( elements)
26+ }
2127}
2228
29+ /// For compatibility with CoreGraphics API.
30+ public class CGMutablePath : CGPath { }
31+
2332public final class CGPathRef {
2433 public var path : CGPath
2534
@@ -31,7 +40,7 @@ public final class CGPathRef {
3140// MARK: - Supporting Types
3241
3342/// A path element.
34- public enum PathElement {
43+ public enum PathElement : Hashable {
3544
3645 /// The path element that starts a new subpath. The element holds a single point for the destination.
3746 case moveToPoint( CGPoint )
Original file line number Diff line number Diff line change @@ -9,6 +9,17 @@ public import Foundation
99extension CGPoint {
1010 public static let zero = CGPoint ( x: . zero, y: . zero)
1111}
12+
13+ extension CGPoint : Hashable {
14+ public func hash( into hasher: inout Hasher ) {
15+ hasher. combine ( x)
16+ hasher. combine ( y)
17+ }
18+
19+ public static func == ( lhs: CGPoint , rhs: CGPoint ) -> Bool {
20+ lhs. x == rhs. x && lhs. y == rhs. y
21+ }
22+ }
1223#endif
1324
1425extension CGPoint : Swift . CustomDebugStringConvertible {
Original file line number Diff line number Diff line change @@ -36,6 +36,17 @@ extension CGRect {
3636
3737 public static let zero = CGRect ( origin: . zero, size: . zero)
3838}
39+
40+ extension CGRect : Swift . Hashable {
41+ public func hash( into hasher: inout Hasher ) {
42+ hasher. combine ( origin)
43+ hasher. combine ( size)
44+ }
45+
46+ public static func == ( lhs: CGRect , rhs: CGRect ) -> Bool {
47+ return lhs. origin == rhs. origin && lhs. size == rhs. size
48+ }
49+ }
3950#endif
4051
4152extension CGRect : Swift . CustomDebugStringConvertible {
Original file line number Diff line number Diff line change @@ -8,6 +8,17 @@ public import Foundation
88extension CGSize {
99 public static let zero = CGSize ( width: . zero, height: . zero)
1010}
11+
12+ extension CGSize : Swift . Hashable {
13+ public func hash( into hasher: inout Hasher ) {
14+ hasher. combine ( width)
15+ hasher. combine ( height)
16+ }
17+
18+ public static func == ( lhs: CGSize , rhs: CGSize ) -> Bool {
19+ lhs. width == rhs. width && lhs. height == rhs. height
20+ }
21+ }
1122#endif
1223
1324extension CGSize : Swift . CustomDebugStringConvertible {
You can’t perform that action at this time.
0 commit comments