Merge remote-tracking branch 'origin/master' into swift-3-indexing-model

This commit is contained in:
Dmitri Gribenko
2016-03-31 09:46:28 -07:00
107 changed files with 4184 additions and 1526 deletions

View File

@@ -430,6 +430,7 @@ public struct Set<Element : Hashable> :
/// Returns an iterator over the members.
///
/// - Complexity: O(1).
@inline(__always)
public func makeIterator() -> SetIterator<Element> {
return _variantStorage.makeIterator()
}
@@ -1055,6 +1056,7 @@ public struct Dictionary<Key : Hashable, Value> :
/// Returns the `Index` for the given key, or `nil` if the key is not
/// present in the dictionary.
@warn_unused_result
@inline(__always)
public func index(forKey key: Key) -> Index? {
// Complexity: amortized O(1) for native storage, O(N) when wrapping an
// NSDictionary.
@@ -1074,6 +1076,7 @@ public struct Dictionary<Key : Hashable, Value> :
/// Writing `nil` as the value for a given key erases that key from
/// `self`.
public subscript(key: Key) -> Value? {
@inline(__always)
get {
return _variantStorage.maybeGet(key)
}
@@ -1149,6 +1152,7 @@ public struct Dictionary<Key : Hashable, Value> :
/// Returns an iterator over the `(Key, Value)` pairs.
///
/// - Complexity: O(1).
@inline(__always)
public func makeIterator() -> DictionaryIterator<Key, Value> {
return _variantStorage.makeIterator()
}
@@ -1968,6 +1972,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
}
@warn_unused_result
@inline(__always)
internal func key(at i: Int) -> Key {
_precondition(i >= 0 && i < capacity)
_sanityCheck(isInitializedEntry(at: i))
@@ -2095,6 +2100,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
/// If the key is not present, returns the position where it could be
/// inserted.
@warn_unused_result
@inline(__always)
internal func _find(key: Key, startBucket: Int)
-> (pos: Index, found: Bool) {
@@ -2191,6 +2197,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
}
@warn_unused_result
@inline(__always)
internal func index(forKey key: Key) -> Index? {
if count == 0 {
// Fast path that avoids computing the hash of the key.
@@ -2226,6 +2233,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
}
@warn_unused_result
@inline(__always)
internal func maybeGet(key: Key) -> Value? {
if count == 0 {
// Fast path that avoids computing the hash of the key.
@@ -2917,6 +2925,7 @@ internal struct _Cocoa${Self}Storage : _HashStorage {
}
@warn_unused_result
@inline(__always)
internal func maybeGet(key: Key) -> Value? {
%if Self == 'Set':
@@ -3178,6 +3187,7 @@ internal enum _Variant${Self}Storage<${TypeParametersDecl}> : _HashStorage {
}
@warn_unused_result
@inline(__always)
internal func index(forKey key: Key) -> Index? {
if _fastPath(guaranteedNative) {
if let nativeIndex = asNative.index(forKey: key) {
@@ -3268,6 +3278,7 @@ internal enum _Variant${Self}Storage<${TypeParametersDecl}> : _HashStorage {
#endif
@warn_unused_result
@inline(__always)
internal func maybeGet(key: Key) -> Value? {
if _fastPath(guaranteedNative) {
return asNative.maybeGet(key)
@@ -3588,6 +3599,7 @@ internal enum _Variant${Self}Storage<${TypeParametersDecl}> : _HashStorage {
/// Returns an iterator over the `(Key, Value)` pairs.
///
/// - Complexity: O(1).
@inline(__always)
internal func makeIterator() -> ${Self}Iterator<${TypeParameters}> {
switch self {
case .native(let owner):
@@ -4056,6 +4068,7 @@ public struct ${Self}Iterator<${TypeParametersDecl}> : IteratorProtocol {
/// element exists.
///
/// - Precondition: No preceding call to `self.next()` has returned `nil`.
@inline(__always)
public mutating func next() -> ${Sequence}? {
if _fastPath(_guaranteedNative) {
return _nativeNext()