@@ -1144,7 +1144,6 @@ extension Collection where SubSequence == Slice<Self> {
11441144 }
11451145}
11461146
1147- // TODO: swift-3-indexing-model - review the following
11481147extension Collection where SubSequence == Self {
11491148 /// Removes and returns the first element of the collection.
11501149 ///
@@ -1153,6 +1152,7 @@ extension Collection where SubSequence == Self {
11531152 ///
11541153 /// - Complexity: O(1)
11551154 public mutating func popFirst( ) -> Iterator . Element ? {
1155+ // TODO: swift-3-indexing-model - review the following
11561156 guard !isEmpty else { return nil }
11571157 let element = first!
11581158 self = self [ index ( after: startIndex) ..< endIndex]
@@ -1200,21 +1200,22 @@ extension Collection {
12001200 var i = makeIterator ( )
12011201 return i. next ( )
12021202 }
1203- // TODO: swift-3-indexing-model - uncomment and replace above ready (or should we still use the iterator one?)
1203+
1204+ // TODO: swift-3-indexing-model - uncomment and replace above ready (or should we still use the iterator one?)
12041205 /// Returns the first element of `self`, or `nil` if `self` is empty.
12051206 ///
12061207 /// - Complexity: O(1)
12071208 // public var first: Iterator.Element? {
12081209 // return isEmpty ? nil : self[startIndex]
12091210 // }
12101211
1211- // TODO: swift-3-indexing-model - review the following
12121212 /// A value less than or equal to the number of elements in the collection.
12131213 ///
12141214 /// - Complexity: O(1) if the collection conforms to
12151215 /// `RandomAccessCollection`; otherwise, O(*n*), where *n* is the length
12161216 /// of the collection.
12171217 public var underestimatedCount : Int {
1218+ // TODO: swift-3-indexing-model - review the following
12181219 return numericCast ( count)
12191220 }
12201221
@@ -1227,7 +1228,7 @@ extension Collection {
12271228 return distance ( from: startIndex, to: endIndex)
12281229 }
12291230
1230- // TODO: swift-3-indexing-model - rename the following to _customIndexOfEquatable(element)?
1231+ // TODO: swift-3-indexing-model - rename the following to _customIndexOfEquatable(element)?
12311232 /// Customization point for `Collection.index(of:)`.
12321233 ///
12331234 /// Define this method if the collection can find an element in less than
@@ -1249,7 +1250,6 @@ extension Collection {
12491250//===----------------------------------------------------------------------===//
12501251
12511252extension Collection {
1252- // TODO: swift-3-indexing-model - review the following
12531253 /// Returns an array containing the results of mapping the given closure
12541254 /// over the sequence's elements.
12551255 ///
@@ -1270,6 +1270,7 @@ extension Collection {
12701270 public func map< T> (
12711271 _ transform: @noescape ( Iterator . Element) throws -> T
12721272 ) rethrows -> [ T ] {
1273+ // TODO: swift-3-indexing-model - review the following
12731274 let count : Int = numericCast ( self . count)
12741275 if count == 0 {
12751276 return [ ]
@@ -1474,10 +1475,12 @@ extension Collection {
14741475 return prefix ( upTo: index ( after: position) )
14751476 }
14761477
1477- // TODO: swift-3-indexing-model - review the following
1478- /// Returns the longest possible subsequences of the sequence, in order, that
1479- /// don't contain elements satisfying the given predicate. Elements that are
1480- /// used to split the sequence are not returned as part of any subsequence.
1478+ /// Returns the longest possible subsequences of the collection, in order,
1479+ /// that don't contain elements satisfying the given predicate.
1480+ ///
1481+ /// The resulting array consists of at most `maxSplits + 1` subsequences.
1482+ /// Elements that are used to split the sequence are not returned as part of
1483+ /// any subsequence.
14811484 ///
14821485 /// The following examples show the effects of the `maxSplits` and
14831486 /// `omittingEmptySubsequences` parameters when splitting a string using a
@@ -1487,7 +1490,7 @@ extension Collection {
14871490 /// let line = "BLANCHE: I don't want realism. I want magic!"
14881491 /// print(line.characters.split(isSeparator: { $0 == " " })
14891492 /// .map(String.init))
1490- /// // Prints "["BLANCHE:", "I", "don't", "want", "realism.", "I", "want", "magic!"]"
1493+ /// // Prints "["BLANCHE:", "I", "don\ 't", "want", "realism.", "I", "want", "magic!"]"
14911494 ///
14921495 /// The second example passes `1` for the `maxSplits` parameter, so the
14931496 /// original string is split just once, into two new strings.
@@ -1505,24 +1508,28 @@ extension Collection {
15051508 /// // Prints "["BLANCHE:", "", "", "I", "don\'t", "want", "realism.", "I", "want", "magic!"]"
15061509 ///
15071510 /// - Parameters:
1508- /// - maxSplits: The maximum number of times to split the sequence, or one
1509- /// less than the number of subsequences to return. If `maxSplits + 1`
1510- /// subsequences are returned, the last one is a suffix of the original
1511- /// sequence containing the remaining elements. `maxSplits` must be
1512- /// greater than or equal to zero.
1511+ /// - maxSplits: The maximum number of times to split the collection, or
1512+ /// one less than the number of subsequences to return. If
1513+ /// `maxSplits + 1` subsequences are returned, the last one is a suffix
1514+ /// of the original collection containing the remaining elements.
1515+ /// `maxSplits` must be greater than or equal to zero. The default value
1516+ /// is `Int.max`.
15131517 /// - omittingEmptySubsequences: If `false`, an empty subsequence is
15141518 /// returned in the result for each pair of consecutive elements
15151519 /// satisfying the `isSeparator` predicate and for each element at the
1516- /// start or end of the sequence satisfying the `isSeparator` predicate.
1520+ /// start or end of the collection satisfying the `isSeparator`
1521+ /// predicate. The default value is `true`.
15171522 /// - isSeparator: A closure that takes an element as an argument and
1518- /// returns a Boolean value indicating whether the sequence should be
1523+ /// returns a Boolean value indicating whether the collection should be
15191524 /// split at that element.
1520- /// - Returns: An array of subsequences, split from this sequence's elements.
1525+ /// - Returns: An array of subsequences, split from this collection's
1526+ /// elements.
15211527 public func split(
15221528 maxSplits: Int = Int . max,
15231529 omittingEmptySubsequences: Bool = true ,
15241530 isSeparator: @noescape ( Iterator . Element) throws -> Bool
15251531 ) rethrows -> [ SubSequence ] {
1532+ // TODO: swift-3-indexing-model - review the following
15261533 _precondition ( maxSplits >= 0 , " Must take zero or more splits " )
15271534
15281535 var result : [ SubSequence ] = [ ]
@@ -1564,64 +1571,67 @@ extension Collection {
15641571 }
15651572}
15661573
1567- // TODO: swift-3-indexing-model - review the following
15681574extension Collection where Iterator. Element : Equatable {
1569- /// Returns the longest possible subsequences of the sequence, in order, that
1570- /// don't contain elements satisfying the given predicate. Elements that are
1571- /// used to split the sequence are not returned as part of any subsequence.
1575+ /// Returns the longest possible subsequences of the collection, in order,
1576+ /// around elements equal to the given element.
1577+ ///
1578+ /// The resulting array consists of at most `maxSplits + 1` subsequences.
1579+ /// Elements that are used to split the collection are not returned as part
1580+ /// of any subsequence.
15721581 ///
15731582 /// The following examples show the effects of the `maxSplits` and
1574- /// `omittingEmptySubsequences` parameters when splitting a string using a
1575- /// closure that matches spaces . The first use of `split` returns each word
1576- /// that was originally separated by one or more spaces.
1583+ /// `omittingEmptySubsequences` parameters when splitting a string at each
1584+ /// space character (" ") . The first use of `split` returns each word that
1585+ /// was originally separated by one or more spaces.
15771586 ///
15781587 /// let line = "BLANCHE: I don't want realism. I want magic!"
1579- /// print(line.characters.split(isSeparator: { $0 == " " } )
1588+ /// print(line.characters.split(separator: " ")
15801589 /// .map(String.init))
1581- /// // Prints "["BLANCHE:", "I", "don't", "want", "realism.", "I", "want", "magic!"]"
1590+ /// // Prints "["BLANCHE:", "I", "don\ 't", "want", "realism.", "I", "want", "magic!"]"
15821591 ///
15831592 /// The second example passes `1` for the `maxSplits` parameter, so the
15841593 /// original string is split just once, into two new strings.
15851594 ///
1586- /// print(line.characters.split(maxSplits: 1, isSeparator: { $0 == " " } )
1595+ /// print(line.characters.split(separator: " ", maxSplits: 1 )
15871596 /// .map(String.init))
15881597 /// // Prints "["BLANCHE:", " I don\'t want realism. I want magic!"]"
15891598 ///
15901599 /// The final example passes `false` for the `omittingEmptySubsequences`
15911600 /// parameter, so the returned array contains empty strings where spaces
15921601 /// were repeated.
15931602 ///
1594- /// print(line.characters.split(omittingEmptySubsequences: false, isSeparator: { $0 == " " } )
1603+ /// print(line.characters.split(separator: " ", omittingEmptySubsequences: false )
15951604 /// .map(String.init))
15961605 /// // Prints "["BLANCHE:", "", "", "I", "don\'t", "want", "realism.", "I", "want", "magic!"]"
15971606 ///
15981607 /// - Parameters:
1599- /// - maxSplits: The maximum number of times to split the sequence, or one
1600- /// less than the number of subsequences to return. If `maxSplits + 1`
1601- /// subsequences are returned, the last one is a suffix of the original
1602- /// sequence containing the remaining elements. `maxSplits` must be
1603- /// greater than or equal to zero.
1608+ /// - separator: The element that should be split upon.
1609+ /// - maxSplits: The maximum number of times to split the collection, or
1610+ /// one less than the number of subsequences to return. If
1611+ /// `maxSplits + 1` subsequences are returned, the last one is a suffix
1612+ /// of the original collection containing the remaining elements.
1613+ /// `maxSplits` must be greater than or equal to zero. The default value
1614+ /// is `Int.max`.
16041615 /// - omittingEmptySubsequences: If `false`, an empty subsequence is
1605- /// returned in the result for each pair of consecutive elements
1606- /// satisfying the `isSeparator` predicate and for each element at the
1607- /// start or end of the sequence satisfying the `isSeparator` predicate.
1608- /// - isSeparator: A closure that takes an element as an argument and
1609- /// returns a Boolean value indicating whether the sequence should be
1610- /// split at that element.
1611- /// - Returns: An array of subsequences, split from this sequence's elements.
1616+ /// returned in the result for each consecutive pair of `separator`
1617+ /// elements in the collection and for each instance of `separator` at
1618+ /// the start or end of the collection. If `true`, only nonempty
1619+ /// subsequences are returned. The default value is `true`.
1620+ /// - Returns: An array of subsequences, split from this collection's
1621+ /// elements.
16121622 public func split(
16131623 separator: Iterator . Element ,
16141624 maxSplits: Int = Int . max,
16151625 omittingEmptySubsequences: Bool = true
16161626 ) -> [ SubSequence ] {
1617- return split (
1618- maxSplits: maxSplits,
1619- omittingEmptySubsequences: omittingEmptySubsequences,
1620- isSeparator: { $0 == separator } )
1627+ // TODO: swift-3-indexing-model - review the following
1628+ return split (
1629+ maxSplits: maxSplits,
1630+ omittingEmptySubsequences: omittingEmptySubsequences,
1631+ isSeparator: { $0 == separator } )
16211632 }
16221633}
16231634
1624- // TODO: swift-3-indexing-model - review the following
16251635extension Collection where SubSequence == Self {
16261636 /// Removes and returns the first element of the collection.
16271637 ///
@@ -1633,6 +1643,7 @@ extension Collection where SubSequence == Self {
16331643 /// - SeeAlso: `popFirst()`
16341644 @discardableResult
16351645 public mutating func removeFirst( ) -> Iterator . Element {
1646+ // TODO: swift-3-indexing-model - review the following
16361647 _precondition ( !isEmpty, " can't remove items from an empty collection " )
16371648 let element = first!
16381649 self = self [ index ( after: startIndex) ..< endIndex]
0 commit comments