16
16
/// - x: A value to compare.
17
17
/// - y: Another value to compare.
18
18
/// - Returns: The lesser of `x` and `y`. If `x` is equal to `y`, returns `x`.
19
+ @_inlineable
19
20
public func min< T : Comparable > ( _ x: T , _ y: T ) -> T {
20
21
// In case `x == y` we pick `x`.
21
22
// This preserves any pre-existing order in case `T` has identity,
@@ -33,6 +34,7 @@ public func min<T : Comparable>(_ x: T, _ y: T) -> T {
33
34
/// - rest: Zero or more additional values.
34
35
/// - Returns: The least of all the arguments. If there are multiple equal
35
36
/// least arguments, the result is the first one.
37
+ @_inlineable
36
38
public func min< T : Comparable > ( _ x: T , _ y: T , _ z: T , _ rest: T ... ) -> T {
37
39
var minValue = min ( min ( x, y) , z)
38
40
// In case `value == minValue`, we pick `minValue`. See min(_:_:).
@@ -48,6 +50,7 @@ public func min<T : Comparable>(_ x: T, _ y: T, _ z: T, _ rest: T...) -> T {
48
50
/// - x: A value to compare.
49
51
/// - y: Another value to compare.
50
52
/// - Returns: The greater of `x` and `y`. If `x` is equal to `y`, returns `y`.
53
+ @_inlineable
51
54
public func max< T : Comparable > ( _ x: T , _ y: T ) -> T {
52
55
// In case `x == y`, we pick `y`. See min(_:_:).
53
56
return y >= x ? y : x
@@ -62,6 +65,7 @@ public func max<T : Comparable>(_ x: T, _ y: T) -> T {
62
65
/// - rest: Zero or more additional values.
63
66
/// - Returns: The greatest of all the arguments. If there are multiple equal
64
67
/// greatest arguments, the result is the last one.
68
+ @_inlineable
65
69
public func max< T : Comparable > ( _ x: T , _ y: T , _ z: T , _ rest: T ... ) -> T {
66
70
var maxValue = max ( max ( x, y) , z)
67
71
// In case `value == maxValue`, we pick `value`. See min(_:_:).
@@ -85,13 +89,18 @@ public func max<T : Comparable>(_ x: T, _ y: T, _ z: T, _ rest: T...) -> T {
85
89
///
86
90
/// To create an instance of `EnumeratedIterator`, call
87
91
/// `enumerated().makeIterator()` on a sequence or collection.
92
+ @_fixed_layout
88
93
public struct EnumeratedIterator <
89
94
Base : IteratorProtocol
90
95
> : IteratorProtocol , Sequence {
96
+ @_versioned
91
97
internal var _base : Base
98
+ @_versioned
92
99
internal var _count : Int
93
100
94
101
/// Construct from a `Base` iterator.
102
+ @_inlineable
103
+ @_versioned
95
104
internal init ( _base: Base ) {
96
105
self . _base = _base
97
106
self . _count = 0
@@ -104,6 +113,7 @@ public struct EnumeratedIterator<
104
113
/// exists.
105
114
///
106
115
/// Once `nil` has been returned, all subsequent calls return `nil`.
116
+ @_inlineable
107
117
public mutating func next( ) -> Element ? {
108
118
guard let b = _base. next ( ) else { return nil }
109
119
let result = ( offset: _count, element: b)
@@ -128,15 +138,20 @@ public struct EnumeratedIterator<
128
138
/// }
129
139
/// // Prints "0: foo"
130
140
/// // Prints "1: bar"
141
+ @_fixed_layout
131
142
public struct EnumeratedSequence < Base : Sequence > : Sequence {
143
+ @_versioned
132
144
internal var _base : Base
133
145
134
146
/// Construct from a `Base` sequence.
147
+ @_inlineable
148
+ @_versioned
135
149
internal init ( _base: Base ) {
136
150
self . _base = _base
137
151
}
138
152
139
153
/// Returns an iterator over the elements of this sequence.
154
+ @_inlineable
140
155
public func makeIterator( ) -> EnumeratedIterator < Base . Iterator > {
141
156
return EnumeratedIterator ( _base: _base. makeIterator ( ) )
142
157
}
0 commit comments