[stdlib] location/formLocation => index/formIndex

This commit is contained in:
Dave Abrahams
2016-04-26 17:46:16 -07:00
parent debde16e2c
commit 9bee5d182f
171 changed files with 1238 additions and 1238 deletions

View File

@@ -96,7 +96,7 @@ extension String.CharacterView : BidirectionalCollection {
/// Returns the next consecutive value after `self`.
///
/// - Precondition: The next value is representable.
// FIXME: swift-3-indexing-model: pull the following logic into UTF8View.location(after: Index)
// FIXME: swift-3-indexing-model: pull the following logic into UTF8View.index(after: Index)
internal func _successor() -> Index {
_precondition(_base != _base._viewEndIndex, "cannot increment endIndex")
return Index(_base: _endBase)
@@ -105,7 +105,7 @@ extension String.CharacterView : BidirectionalCollection {
/// Returns the previous consecutive value before `self`.
///
/// - Precondition: The previous value is representable.
// FIXME: swift-3-indexing-model: pull the following logic into UTF8View.location(before: Index)
// FIXME: swift-3-indexing-model: pull the following logic into UTF8View.index(before: Index)
internal func _predecessor() -> Index {
_precondition(_base != _base._viewStartIndex,
"cannot decrement startIndex")
@@ -155,7 +155,7 @@ extension String.CharacterView : BidirectionalCollection {
var gcb0 = graphemeClusterBreakProperty.getPropertyRawValue(
unicodeScalars[start].value)
unicodeScalars.formLocation(after: &start)
unicodeScalars.formIndex(after: &start)
while start != end {
// FIXME(performance): consider removing this "fast path". A branch
@@ -170,7 +170,7 @@ extension String.CharacterView : BidirectionalCollection {
break
}
gcb0 = gcb1
unicodeScalars.formLocation(after: &start)
unicodeScalars.formIndex(after: &start)
}
return start._position - startIndexUTF16
@@ -196,14 +196,14 @@ extension String.CharacterView : BidirectionalCollection {
var graphemeClusterStart = end
unicodeScalars.formLocation(before: &graphemeClusterStart)
unicodeScalars.formIndex(before: &graphemeClusterStart)
var gcb0 = graphemeClusterBreakProperty.getPropertyRawValue(
unicodeScalars[graphemeClusterStart].value)
var graphemeClusterStartUTF16 = graphemeClusterStart._position
while graphemeClusterStart != start {
unicodeScalars.formLocation(before: &graphemeClusterStart)
unicodeScalars.formIndex(before: &graphemeClusterStart)
let gcb1 = graphemeClusterBreakProperty.getPropertyRawValue(
unicodeScalars[graphemeClusterStart].value)
if segmenter.isBoundary(gcb1, gcb0) {
@@ -233,21 +233,21 @@ extension String.CharacterView : BidirectionalCollection {
///
/// `endIndex` is not a valid argument to `subscript`, and is always
/// reachable from `startIndex` by zero or more applications of
/// `location(after:)`.
/// `index(after:)`.
public var endIndex: Index {
return Index(_base: unicodeScalars.endIndex)
}
// TODO: swift-3-indexing-model - add docs
@warn_unused_result
public func location(after i: Index) -> Index {
public func index(after i: Index) -> Index {
// FIXME: swift-3-indexing-model: range check i?
return i._successor()
}
// TODO: swift-3-indexing-model - add docs
@warn_unused_result
public func location(before i: Index) -> Index {
public func index(before i: Index) -> Index {
return i._predecessor()
}