File tree 8 files changed +16
-73
lines changed
Tests/DataStructuresTests
8 files changed +16
-73
lines changed Original file line number Diff line number Diff line change 4
4
language : generic
5
5
sudo : required
6
6
dist : trusty
7
- osx_image : xcode10
7
+ osx_image : xcode10.2
8
8
install :
9
9
- eval "$(curl -sL https://swiftenv.fuller.li/install.sh)"
10
10
env :
11
- - SWIFT_VERSION=4.2
11
+ - SWIFT_VERSION=5.0
12
12
script :
13
13
- swift package update
14
14
- swift test -c release
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ extension Collection {
57
57
extension Sequence {
58
58
59
59
/// - Returns: `Zip2Sequence` of 2-tuples composed of adjacent values.
60
- public var pairs : Zip2Sequence < Self , SubSequence > {
60
+ public var pairs : Zip2Sequence < Self , DropFirstSequence < Self > > {
61
61
return zip ( self , dropFirst ( ) )
62
62
}
63
63
}
Original file line number Diff line number Diff line change @@ -109,10 +109,11 @@ public struct Matrix <Element> {
109
109
}
110
110
}
111
111
112
- extension Matrix : CollectionWrapping {
112
+ extension Matrix : SequenceWrapping {
113
113
114
- // MARK: - CollectionWrapping
114
+ // MARK: - SequenceWrapping
115
115
116
+ /// - returns: Underlying `Collection`.
116
117
public var base : [ Element ] {
117
118
return grid
118
119
}
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ extension Metatype: Hashable {
42
42
43
43
/// - Returns: A unique hash value for the metatype wrapped-up herein.
44
44
@inlinable
45
- public var hashValue : Int {
46
- return ObjectIdentifier ( base) . hashValue
45
+ public func hash ( into hasher : inout Hasher ) {
46
+ hasher . combine ( ObjectIdentifier ( base) . hashValue)
47
47
}
48
48
}
Original file line number Diff line number Diff line change @@ -94,38 +94,3 @@ extension NewType where Value: Numeric {
94
94
}
95
95
96
96
extension NewType where Value: SignedNumeric { }
97
-
98
- extension NewType where Value: Sequence {
99
- public func makeIterator( ) -> Value . Iterator {
100
- return value. makeIterator ( )
101
- }
102
- }
103
-
104
- extension NewType where Value: Collection {
105
-
106
- public typealias Iterator = Value . Iterator
107
-
108
- /// Start index.
109
- public var startIndex : Value . Index {
110
- return value. startIndex
111
- }
112
-
113
- /// End index.
114
- public var endIndex : Value . Index {
115
- return value. endIndex
116
- }
117
-
118
- /// Index after given index `i`.
119
- public func index( after i: Value . Index ) -> Value . Index {
120
- return value. index ( after: i)
121
- }
122
-
123
- public var indices : Value . Indices {
124
- return value. indices
125
- }
126
-
127
- /// - returns: Element at the given `index`.
128
- public subscript ( index: Value . Index ) -> Value . Element {
129
- return value [ index]
130
- }
131
- }
Original file line number Diff line number Diff line change 21
21
///
22
22
/// In the `init` method of the conforming `struct`, set the value of this private `var` with
23
23
/// the given `sequence`.
24
- ///
25
- /// - TODO: Consider removing `ExpressibleByArrayLiteral` and `init` requirements.
26
- public protocol SequenceWrapping : Sequence , ExpressibleByArrayLiteral {
24
+ public protocol SequenceWrapping : Sequence {
27
25
28
26
// MARK: Associated Types
29
27
30
- // MARK: - Instance Properties
31
-
32
- /// `AnySequence` wrapper that provides shade for the domain specific implementation.
33
- var sequence : AnySequence < Element > { get }
28
+ /// Wrapped `Collection`-conforming type.
29
+ associatedtype Base : Sequence
34
30
35
- // MARK: - Initializers
31
+ // MARK: - Instance Properties
36
32
37
- /// Create an `SequenceWrapping` with a `Sequence` .
38
- init < S > ( _ sequence : S ) where S : Sequence , S . Element == Element
33
+ /// Wrapped `Collection`-conforming type .
34
+ var base : Base { get }
39
35
}
40
36
41
37
extension SequenceWrapping {
42
38
43
39
// MARK: - Sequence
44
40
45
41
/// - returns a generator over the elements of this sequence.
46
- public func makeIterator( ) -> AnyIterator < Element > {
47
-
48
- let iterator = sequence. makeIterator ( )
49
-
50
- return AnyIterator {
51
- return iterator. next ( )
52
- }
42
+ public func makeIterator( ) -> Base . Iterator {
43
+ return base. makeIterator ( )
53
44
}
54
45
}
Original file line number Diff line number Diff line change @@ -42,16 +42,4 @@ class NewTypeTests: XCTestCase {
42
42
let n : SN = 1
43
43
let _ = - n
44
44
}
45
-
46
- func testSequence( ) {
47
- struct S : NewType , Sequence { let value : [ Int ] }
48
- let s = S ( [ 1 , 2 , 3 ] )
49
- let _ = s. map { $0 }
50
- }
51
-
52
- func testCollection( ) {
53
- struct C : NewType , Collection { let value : [ Int ] }
54
- let c = C ( [ 1 , 2 , 3 ] )
55
- let _ = c. count
56
- }
57
45
}
Original file line number Diff line number Diff line change @@ -277,12 +277,10 @@ extension MutableGraphTests {
277
277
278
278
extension NewTypeTests {
279
279
static let __allTests = [
280
- ( " testCollection " , testCollection) ,
281
280
( " testComparable " , testComparable) ,
282
281
( " testExpressibleByFloatLiteral " , testExpressibleByFloatLiteral) ,
283
282
( " testExpressibleByIntegerLiteral " , testExpressibleByIntegerLiteral) ,
284
283
( " testNumeric " , testNumeric) ,
285
- ( " testSequence " , testSequence) ,
286
284
( " testSignedNumeric " , testSignedNumeric) ,
287
285
]
288
286
}
You can’t perform that action at this time.
0 commit comments