@@ -93,29 +93,6 @@ extension String.CharacterView : BidirectionalCollection {
93
93
self . _countUTF16 = _countUTF16
94
94
}
95
95
96
- /// Returns the next consecutive value after `self`.
97
- ///
98
- /// - Precondition: The next value is representable.
99
- // FIXME: swift-3-indexing-model: pull the following logic into UTF8View.index(after: Index)
100
- internal func _successor( ) -> Index {
101
- _precondition ( _base != _base. _viewEndIndex, " cannot increment endIndex " )
102
- return Index ( _base: _endBase)
103
- }
104
-
105
- /// Returns the previous consecutive value before `self`.
106
- ///
107
- /// - Precondition: The previous value is representable.
108
- // FIXME: swift-3-indexing-model: pull the following logic into UTF8View.index(before: Index)
109
- internal func _predecessor( ) -> Index {
110
- _precondition ( _base != _base. _viewStartIndex,
111
- " cannot decrement startIndex " )
112
- let predecessorLengthUTF16 =
113
- Index . _measureExtendedGraphemeClusterBackward ( from: _base)
114
- return Index (
115
- _base: UnicodeScalarView . Index (
116
- _utf16Index - predecessorLengthUTF16, _base. _core) )
117
- }
118
-
119
96
internal let _base : UnicodeScalarView . Index
120
97
121
98
/// The count of this extended grapheme cluster in UTF-16 code units.
@@ -238,17 +215,28 @@ extension String.CharacterView : BidirectionalCollection {
238
215
return Index ( _base: unicodeScalars. endIndex)
239
216
}
240
217
241
- // TODO: swift-3-indexing-model - add docs
218
+ /// Returns the next consecutive position after `i`.
219
+ ///
220
+ /// - Precondition: The next position is valid.
242
221
@warn_unused_result
243
222
public func index( after i: Index ) -> Index {
244
- // FIXME: swift-3-indexing-model: range check i?
245
- return i . _successor ( )
223
+ _precondition ( i . _base != i . _base . _viewEndIndex , " cannot increment endIndex " )
224
+ return Index ( _base : i . _endBase )
246
225
}
247
226
248
- // TODO: swift-3-indexing-model - add docs
227
+ /// Returns the previous consecutive position before `i`.
228
+ ///
229
+ /// - Precondition: The previous position is valid.
249
230
@warn_unused_result
250
231
public func index( before i: Index ) -> Index {
251
- return i. _predecessor ( )
232
+ // FIXME: swift-3-indexing-model: range check i?
233
+ _precondition ( i. _base != i. _base. _viewStartIndex,
234
+ " cannot decrement startIndex " )
235
+ let predecessorLengthUTF16 =
236
+ Index . _measureExtendedGraphemeClusterBackward ( from: i. _base)
237
+ return Index (
238
+ _base: UnicodeScalarView . Index (
239
+ i. _utf16Index - predecessorLengthUTF16, i. _base. _core) )
252
240
}
253
241
254
242
/// Access the `Character` at `position`.
0 commit comments