[stdlib] Propagate BidirectionalIndexType docs

193 undocumented public non-operator APIs remain in core

Swift SVN r22225
This commit is contained in:
Dave Abrahams
2014-09-23 19:35:31 +00:00
parent 9623c52879
commit 218d25eb5a
8 changed files with 24 additions and 3 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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())

View File

@@ -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

View File

@@ -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())
}

View File

@@ -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")

View File

@@ -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]

View File

@@ -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
}