@@ -60,11 +60,11 @@ public protocol _IndexableBase {
60
60
61
61
// The declaration of _Element and subscript here is a trick used to
62
62
// break a cyclic conformance/deduction that Swift can't handle. We
63
- // need something other than a Collection.Iterator. Element that can
63
+ // need something other than a Collection.Element that can
64
64
// be used as IndexingIterator<T>'s Element. Here we arrange for
65
65
// the Collection itself to have an Element type that's deducible from
66
66
// its subscript. Ideally we'd like to constrain this Element to be the same
67
- // as Collection.Iterator. Element (see below), but we have no way of
67
+ // as Collection.Element (see below), but we have no way of
68
68
// expressing it today.
69
69
associatedtype _Element
70
70
@@ -652,7 +652,6 @@ public protocol Collection : _Indexable, Sequence
652
652
/// supplying `IndexingIterator` as its associated `Iterator`
653
653
/// type.
654
654
associatedtype Iterator = IndexingIterator < Self >
655
- where Self. Iterator. Element == _Element
656
655
657
656
// FIXME(ABI)#179 (Type checker): Needed here so that the `Iterator` is properly deduced from
658
657
// a custom `makeIterator()` function. Otherwise we get an
@@ -672,10 +671,9 @@ public protocol Collection : _Indexable, Sequence
672
671
= Slice < Self >
673
672
where SubSequence. SubSequence == SubSequence
674
673
// FIXME(ABI) (Revert Where Clauses): and this where clause:
675
- , Iterator . Element == SubSequence . Iterator . Element
674
+ , Element == SubSequence . Element
676
675
, SubSequence. Index == Index
677
676
678
-
679
677
// FIXME(ABI)#98 (Recursive Protocol Constraints):
680
678
// FIXME(ABI)#99 (Associated Types with where clauses):
681
679
// associatedtype SubSequence : Collection
@@ -707,7 +705,7 @@ public protocol Collection : _Indexable, Sequence
707
705
/// `endIndex` property.
708
706
///
709
707
/// - Complexity: O(1)
710
- subscript( position: Index) -> Iterator . Element { get }
708
+ subscript( position: Index) -> Element { get }
711
709
712
710
/// Accesses a contiguous subrange of the collection's elements.
713
711
///
@@ -740,7 +738,7 @@ public protocol Collection : _Indexable, Sequence
740
738
// FIXME(ABI) (Revert Where Clauses): Remove these two conformances
741
739
: _Indexable, Sequence
742
740
= DefaultIndices< Self>
743
- where Indices. Iterator . Element == Index,
741
+ where Indices. Element == Index,
744
742
Indices . Index == Index
745
743
// FIXME(ABI) (Revert Where Clauses): Remove this where clause
746
744
, Indices . SubSequence == Indices
@@ -911,7 +909,7 @@ public protocol Collection : _Indexable, Sequence
911
909
/// otherwise, `nil`.
912
910
///
913
911
/// - Complexity: O(*n*)
914
- func _customIndexOfEquatableElement( _ element: Iterator . Element ) -> Index ? ?
912
+ func _customIndexOfEquatableElement( _ element: Element ) -> Index ? ?
915
913
916
914
/// The first element of the collection.
917
915
///
@@ -922,7 +920,7 @@ public protocol Collection : _Indexable, Sequence
922
920
/// print(firstNumber)
923
921
/// }
924
922
/// // Prints "10"
925
- var first: Iterator . Element? { get }
923
+ var first: Element? { get }
926
924
927
925
/// Returns an index that is the specified distance from the given index.
928
926
///
@@ -1317,7 +1315,7 @@ extension Collection where SubSequence == Self {
1317
1315
///
1318
1316
/// - Complexity: O(1)
1319
1317
@_inlineable
1320
- public mutating func popFirst( ) -> Iterator . Element ? {
1318
+ public mutating func popFirst( ) -> Element ? {
1321
1319
// TODO: swift-3-indexing-model - review the following
1322
1320
guard !isEmpty else { return nil }
1323
1321
let element = first!
@@ -1360,23 +1358,20 @@ extension Collection {
1360
1358
/// }
1361
1359
/// // Prints "10"
1362
1360
@_inlineable
1363
- public var first : Iterator . Element ? {
1364
- @inline ( __always)
1365
- get {
1366
- // NB: Accessing `startIndex` may not be O(1) for some lazy collections,
1367
- // so instead of testing `isEmpty` and then returning the first element,
1368
- // we'll just rely on the fact that the iterator always yields the
1369
- // first element first.
1370
- var i = makeIterator ( )
1371
- return i. next ( )
1372
- }
1361
+ public var first : Element ? {
1362
+ // NB: Accessing `startIndex` may not be O(1) for some lazy collections,
1363
+ // so instead of testing `isEmpty` and then returning the first element,
1364
+ // we'll just rely on the fact that the iterator always yields the
1365
+ // first element first.
1366
+ var i = makeIterator ( )
1367
+ return i. next ( )
1373
1368
}
1374
1369
1375
1370
// TODO: swift-3-indexing-model - uncomment and replace above ready (or should we still use the iterator one?)
1376
1371
/// Returns the first element of `self`, or `nil` if `self` is empty.
1377
1372
///
1378
1373
/// - Complexity: O(1)
1379
- // public var first: Iterator. Element? {
1374
+ // public var first: Element? {
1380
1375
// return isEmpty ? nil : self[startIndex]
1381
1376
// }
1382
1377
@@ -1448,7 +1443,7 @@ extension Collection {
1448
1443
/// sequence.
1449
1444
@_inlineable
1450
1445
public func map< T> (
1451
- _ transform: ( Iterator . Element ) throws -> T
1446
+ _ transform: ( Element ) throws -> T
1452
1447
) rethrows -> [ T ] {
1453
1448
// TODO: swift-3-indexing-model - review the following
1454
1449
let count : Int = numericCast ( self . count)
@@ -1536,7 +1531,7 @@ extension Collection {
1536
1531
/// - Complexity: O(*n*), where *n* is the length of the collection.
1537
1532
@_inlineable
1538
1533
public func drop(
1539
- while predicate: ( Iterator . Element ) throws -> Bool
1534
+ while predicate: ( Element ) throws -> Bool
1540
1535
) rethrows -> SubSequence {
1541
1536
var start = startIndex
1542
1537
while try start != endIndex && predicate ( self [ start] ) {
@@ -1582,7 +1577,7 @@ extension Collection {
1582
1577
/// - Complexity: O(*n*), where *n* is the length of the collection.
1583
1578
@_inlineable
1584
1579
public func prefix(
1585
- while predicate: ( Iterator . Element ) throws -> Bool
1580
+ while predicate: ( Element ) throws -> Bool
1586
1581
) rethrows -> SubSequence {
1587
1582
var end = startIndex
1588
1583
while try end != endIndex && predicate ( self [ end] ) {
@@ -1783,7 +1778,7 @@ extension Collection {
1783
1778
public func split(
1784
1779
maxSplits: Int = Int . max,
1785
1780
omittingEmptySubsequences: Bool = true ,
1786
- whereSeparator isSeparator: ( Iterator . Element ) throws -> Bool
1781
+ whereSeparator isSeparator: ( Element ) throws -> Bool
1787
1782
) rethrows -> [ SubSequence ] {
1788
1783
// TODO: swift-3-indexing-model - review the following
1789
1784
_precondition ( maxSplits >= 0 , " Must take zero or more splits " )
@@ -1827,7 +1822,7 @@ extension Collection {
1827
1822
}
1828
1823
}
1829
1824
1830
- extension Collection where Iterator . Element : Equatable {
1825
+ extension Collection where Element : Equatable {
1831
1826
/// Returns the longest possible subsequences of the collection, in order,
1832
1827
/// around elements equal to the given element.
1833
1828
///
@@ -1874,7 +1869,7 @@ extension Collection where Iterator.Element : Equatable {
1874
1869
/// elements.
1875
1870
@_inlineable
1876
1871
public func split(
1877
- separator: Iterator . Element ,
1872
+ separator: Element ,
1878
1873
maxSplits: Int = Int . max,
1879
1874
omittingEmptySubsequences: Bool = true
1880
1875
) -> [ SubSequence ] {
@@ -1897,7 +1892,7 @@ extension Collection where SubSequence == Self {
1897
1892
/// - SeeAlso: `popFirst()`
1898
1893
@_inlineable
1899
1894
@discardableResult
1900
- public mutating func removeFirst( ) -> Iterator . Element {
1895
+ public mutating func removeFirst( ) -> Element {
1901
1896
// TODO: swift-3-indexing-model - review the following
1902
1897
_precondition ( !isEmpty, " can't remove items from an empty collection " )
1903
1898
let element = first!
@@ -1960,16 +1955,16 @@ extension Collection {
1960
1955
public func split(
1961
1956
_ maxSplit: Int = Int . max,
1962
1957
allowEmptySlices: Bool = false ,
1963
- whereSeparator isSeparator: ( Iterator . Element ) throws -> Bool
1958
+ whereSeparator isSeparator: ( Element ) throws -> Bool
1964
1959
) rethrows -> [ SubSequence ] {
1965
1960
Builtin . unreachable ( )
1966
1961
}
1967
1962
}
1968
1963
1969
- extension Collection where Iterator . Element : Equatable {
1964
+ extension Collection where Element : Equatable {
1970
1965
@available ( * , unavailable, message: " Please use split(separator:maxSplits:omittingEmptySubsequences:) instead " )
1971
1966
public func split(
1972
- _ separator: Iterator . Element ,
1967
+ _ separator: Element ,
1973
1968
maxSplit: Int = Int . max,
1974
1969
allowEmptySlices: Bool = false
1975
1970
) -> [ SubSequence ] {
0 commit comments