mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Mechanically add "Type" to the end of any protocol names that don't end in "Type," "ible," or "able." Also, drop "Type" from the end of any associated type names, except for those of the *LiteralConvertible protocols. There are obvious improvements to make in some of these names, which can be handled with separate commits. Fixes <rdar://problem/17165920> Protocols `Integer` etc should get uglier names. Swift SVN r19883
51 lines
1.4 KiB
Swift
51 lines
1.4 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See http://swift.org/LICENSE.txt for license information
|
|
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
public struct ZipGenerator2<
|
|
E0 : GeneratorType, E1 : GeneratorType
|
|
> : GeneratorType {
|
|
public typealias Element = (E0.Element,E1.Element)
|
|
|
|
public init(_ e0: E0, _ e1: E1) {
|
|
baseStreams = (e0,e1)
|
|
}
|
|
|
|
public mutating func next() -> Element? {
|
|
var e0 = baseStreams.0.next()
|
|
if !e0 { return .None }
|
|
var e1 = baseStreams.1.next()
|
|
if !e1 { return .None }
|
|
return .Some((e0!, e1!))
|
|
}
|
|
|
|
var baseStreams : (E0,E1)
|
|
}
|
|
|
|
public struct Zip2<S0: SequenceType, S1: SequenceType> : SequenceType
|
|
{
|
|
public typealias Stream1 = S0.Generator
|
|
public typealias Stream2 = S1.Generator
|
|
public typealias Generator = ZipGenerator2<Stream1, Stream2>
|
|
|
|
public init(_ s0: S0, _ s1: S1) {
|
|
sequences = (s0,s1)
|
|
}
|
|
|
|
public func generate() -> Generator {
|
|
return Generator(
|
|
sequences.0.generate(),
|
|
sequences.1.generate())
|
|
}
|
|
|
|
var sequences: (S0,S1)
|
|
}
|