mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[stdlib] Propagate BidirectionalIndexType docs
193 undocumented public non-operator APIs remain in core Swift SVN r22225
This commit is contained in:
@@ -27,8 +27,9 @@ public enum Bit : Int, RandomAccessIndexType, Reflectable {
|
||||
return .One
|
||||
}
|
||||
|
||||
/// Return the previous consecutive value in a discrete sequence of
|
||||
/// `Bit` values.
|
||||
/// Returns the previous consecutive value before `self`.
|
||||
///
|
||||
/// Requires: `self != .Zero`.
|
||||
public func predecessor() -> Bit {
|
||||
_precondition(self == .One, "Can't decrement past zero")
|
||||
return .Zero
|
||||
|
||||
@@ -153,7 +153,9 @@ struct ${Index}<
|
||||
}
|
||||
|
||||
% if traversal == 'Bidirectional':
|
||||
/// Return an index for the previous position.
|
||||
/// Returns the previous consecutive value before `self`.
|
||||
///
|
||||
/// Requires: the previous value is representable.
|
||||
func predecessor() -> ${Index} {
|
||||
|
||||
var outer = _outer
|
||||
|
||||
@@ -1680,6 +1680,9 @@ public struct DictionaryIndex<Key : Hashable, Value> :
|
||||
|
||||
public typealias Index = DictionaryIndex<Key, Value>
|
||||
|
||||
/// Returns the previous consecutive value before `self`.
|
||||
///
|
||||
/// Requires: the previous value is representable.
|
||||
public func predecessor() -> Index {
|
||||
if _fastPath(_guaranteedNative) {
|
||||
return ._Native(_nativeIndex.predecessor())
|
||||
|
||||
@@ -287,6 +287,9 @@ extension ${Self} : RandomAccessIndexType {
|
||||
func successor() -> ${Self} {
|
||||
return self &+ 1
|
||||
}
|
||||
/// Returns the previous consecutive value before `self`.
|
||||
///
|
||||
/// Requires: the previous value is representable.
|
||||
@transparent public
|
||||
func predecessor() -> ${Self} {
|
||||
return self &- 1
|
||||
|
||||
@@ -40,6 +40,9 @@ public struct ${Index}<I: ${IndexProtocol}> : ${IndexProtocol} {
|
||||
return ${Index}(_base.predecessor())
|
||||
}
|
||||
|
||||
/// Returns the previous consecutive value before `self`.
|
||||
///
|
||||
/// Requires: the previous value is representable.
|
||||
public func predecessor() -> ${Index} {
|
||||
return ${Index}(_base.successor())
|
||||
}
|
||||
|
||||
@@ -345,6 +345,9 @@ extension String : CollectionType {
|
||||
return Index(_endBase)
|
||||
}
|
||||
|
||||
/// Returns the previous consecutive value before `self`.
|
||||
///
|
||||
/// Requires: the previous value is representable.
|
||||
public func predecessor() -> Index {
|
||||
_precondition(_base != _base._viewStartIndex,
|
||||
"can not decrement startIndex")
|
||||
|
||||
@@ -61,6 +61,9 @@ extension String {
|
||||
return Index(_position + length, _core)
|
||||
}
|
||||
|
||||
/// Returns the previous consecutive value before `self`.
|
||||
///
|
||||
/// Requires: the previous value is representable.
|
||||
public func predecessor() -> Index {
|
||||
var i = _position
|
||||
let codeUnit = _core[--i]
|
||||
|
||||
@@ -358,6 +358,9 @@ public struct ${Self}<T>
|
||||
public func successor() -> ${Self} {
|
||||
return self + 1
|
||||
}
|
||||
/// Returns the previous consecutive value before `self`.
|
||||
///
|
||||
/// Requires: the previous value is representable.
|
||||
public func predecessor() -> ${Self} {
|
||||
return self - 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user