11
11
//===----------------------------------------------------------------------===//
12
12
13
13
/// A fixed-size array.
14
- @available ( SwiftStdlib 6 . 1 , * )
14
+ @available ( SwiftStdlib 6 . 2 , * )
15
15
@frozen
16
16
public struct Slab < let count: Int , Element: ~ Copyable> : ~ Copyable {
17
17
@usableFromInline
18
18
internal let _storage : Builtin . FixedArray < count , Element >
19
19
}
20
20
21
- @available ( SwiftStdlib 6 . 1 , * )
21
+ @available ( SwiftStdlib 6 . 2 , * )
22
22
extension Slab : Copyable where Element: Copyable { }
23
23
24
- @available ( SwiftStdlib 6 . 1 , * )
24
+ @available ( SwiftStdlib 6 . 2 , * )
25
25
extension Slab : BitwiseCopyable where Element: BitwiseCopyable { }
26
26
27
- @available ( SwiftStdlib 6 . 1 , * )
27
+ @available ( SwiftStdlib 6 . 2 , * )
28
28
extension Slab : @unchecked Sendable where Element: Sendable & ~ Copyable { }
29
29
30
30
//===----------------------------------------------------------------------===//
31
31
// Address & Buffer
32
32
//===----------------------------------------------------------------------===//
33
33
34
- @available ( SwiftStdlib 6 . 1 , * )
34
+ @available ( SwiftStdlib 6 . 2 , * )
35
35
extension Slab where Element: ~ Copyable {
36
36
/// Returns a read-only pointer to the first element in the vector.
37
- @available ( SwiftStdlib 6 . 1 , * )
37
+ @available ( SwiftStdlib 6 . 2 , * )
38
38
@_alwaysEmitIntoClient
39
39
@_transparent
40
40
internal var _address : UnsafePointer < Element > {
41
41
UnsafePointer < Element > ( Builtin . unprotectedAddressOfBorrow ( self ) )
42
42
}
43
43
44
44
/// Returns a buffer pointer over the entire vector.
45
- @available ( SwiftStdlib 6 . 1 , * )
45
+ @available ( SwiftStdlib 6 . 2 , * )
46
46
@_alwaysEmitIntoClient
47
47
@_transparent
48
48
internal var _buffer : UnsafeBufferPointer < Element > {
49
49
UnsafeBufferPointer < Element > ( start: _address, count: count)
50
50
}
51
51
52
52
/// Returns a mutable pointer to the first element in the vector.
53
- @available ( SwiftStdlib 6 . 1 , * )
53
+ @available ( SwiftStdlib 6 . 2 , * )
54
54
@_alwaysEmitIntoClient
55
55
@_transparent
56
56
internal var _mutableAddress : UnsafeMutablePointer < Element > {
@@ -60,7 +60,7 @@ extension Slab where Element: ~Copyable {
60
60
}
61
61
62
62
/// Returns a mutable buffer pointer over the entire vector.
63
- @available ( SwiftStdlib 6 . 1 , * )
63
+ @available ( SwiftStdlib 6 . 2 , * )
64
64
@_alwaysEmitIntoClient
65
65
@_transparent
66
66
internal var _mutableBuffer : UnsafeMutableBufferPointer < Element > {
@@ -71,7 +71,7 @@ extension Slab where Element: ~Copyable {
71
71
72
72
/// Returns the given raw pointer, which points at an uninitialized vector
73
73
/// instance, to a mutable buffer suitable for initialization.
74
- @available ( SwiftStdlib 6 . 1 , * )
74
+ @available ( SwiftStdlib 6 . 2 , * )
75
75
@_alwaysEmitIntoClient
76
76
@_transparent
77
77
internal static func _initializationBuffer(
@@ -88,7 +88,7 @@ extension Slab where Element: ~Copyable {
88
88
// Initialization APIs
89
89
//===----------------------------------------------------------------------===//
90
90
91
- @available ( SwiftStdlib 6 . 1 , * )
91
+ @available ( SwiftStdlib 6 . 2 , * )
92
92
extension Slab where Element: ~ Copyable {
93
93
/// Initializes every element in this vector running the given closure value
94
94
/// that returns the element to emplace at the given index.
@@ -102,7 +102,7 @@ extension Slab where Element: ~Copyable {
102
102
///
103
103
/// - Parameter body: A closure that returns an owned `Element` to emplace at
104
104
/// the passed in index.
105
- @available ( SwiftStdlib 6 . 1 , * )
105
+ @available ( SwiftStdlib 6 . 2 , * )
106
106
@_alwaysEmitIntoClient
107
107
public init < E: Error > ( _ body: ( Int ) throws ( E ) -> Element ) throws ( E) {
108
108
self = try Builtin . emplace { ( rawPtr) throws ( E) -> ( ) in
@@ -141,7 +141,7 @@ extension Slab where Element: ~Copyable {
141
141
/// - Parameter next: A closure that passes in an immutable borrow reference
142
142
/// of the given first element of the vector which returns
143
143
/// an owned `Element` instance to insert into the vector.
144
- @available ( SwiftStdlib 6 . 1 , * )
144
+ @available ( SwiftStdlib 6 . 2 , * )
145
145
@_alwaysEmitIntoClient
146
146
public init < E: Error > (
147
147
first: consuming Element ,
@@ -175,12 +175,12 @@ extension Slab where Element: ~Copyable {
175
175
}
176
176
}
177
177
178
- @available ( SwiftStdlib 6 . 1 , * )
178
+ @available ( SwiftStdlib 6 . 2 , * )
179
179
extension Slab where Element: Copyable {
180
180
/// Initializes every element in this vector to a copy of the given value.
181
181
///
182
182
/// - Parameter value: The instance to initialize this vector with.
183
- @available ( SwiftStdlib 6 . 1 , * )
183
+ @available ( SwiftStdlib 6 . 2 , * )
184
184
@_alwaysEmitIntoClient
185
185
public init ( repeating value: Element ) {
186
186
self = Builtin . emplace {
@@ -195,22 +195,22 @@ extension Slab where Element: Copyable {
195
195
// Collection APIs
196
196
//===----------------------------------------------------------------------===//
197
197
198
- @available ( SwiftStdlib 6 . 1 , * )
198
+ @available ( SwiftStdlib 6 . 2 , * )
199
199
extension Slab where Element: ~ Copyable {
200
200
/// The type of the container's elements.
201
- @available ( SwiftStdlib 6 . 1 , * )
201
+ @available ( SwiftStdlib 6 . 2 , * )
202
202
public typealias Element = Element
203
203
204
204
/// A type that represents a position in the collection.
205
205
///
206
206
/// Valid indices consist of the position of every element and a
207
207
/// "past the end" position that's not valid for use as a subscript
208
208
/// argument.
209
- @available ( SwiftStdlib 6 . 1 , * )
209
+ @available ( SwiftStdlib 6 . 2 , * )
210
210
public typealias Index = Int
211
211
212
212
/// The number of elements in the collection.
213
- @available ( SwiftStdlib 6 . 1 , * )
213
+ @available ( SwiftStdlib 6 . 2 , * )
214
214
@_alwaysEmitIntoClient
215
215
@_transparent
216
216
public static var count : Int {
@@ -220,7 +220,7 @@ extension Slab where Element: ~Copyable {
220
220
/// The number of elements in the collection.
221
221
///
222
222
/// - Complexity: O(1)
223
- @available ( SwiftStdlib 6 . 1 , * )
223
+ @available ( SwiftStdlib 6 . 2 , * )
224
224
@_alwaysEmitIntoClient
225
225
@_transparent
226
226
public var count : Int {
@@ -230,7 +230,7 @@ extension Slab where Element: ~Copyable {
230
230
/// The position of the first element in a nonempty collection.
231
231
///
232
232
/// If the collection is empty, `startIndex` is equal to `endIndex`.
233
- @available ( SwiftStdlib 6 . 1 , * )
233
+ @available ( SwiftStdlib 6 . 2 , * )
234
234
@_alwaysEmitIntoClient
235
235
@_transparent
236
236
public var startIndex : Int {
@@ -252,7 +252,7 @@ extension Slab where Element: ~Copyable {
252
252
/// // Prints "[30, 40, 50]"
253
253
///
254
254
/// If the collection is empty, `endIndex` is equal to `startIndex`.
255
- @available ( SwiftStdlib 6 . 1 , * )
255
+ @available ( SwiftStdlib 6 . 2 , * )
256
256
@_alwaysEmitIntoClient
257
257
@_transparent
258
258
public var endIndex : Int {
@@ -276,7 +276,7 @@ extension Slab where Element: ~Copyable {
276
276
/// i = c.index(after: i)
277
277
/// }
278
278
/// // c == MyFancyCollection([2, 4, 6, 8, 10])
279
- @available ( SwiftStdlib 6 . 1 , * )
279
+ @available ( SwiftStdlib 6 . 2 , * )
280
280
@_alwaysEmitIntoClient
281
281
@_transparent
282
282
public var indices : Range < Int > {
@@ -288,7 +288,7 @@ extension Slab where Element: ~Copyable {
288
288
/// - Parameter i: A valid index of the collection. `i` must be less than
289
289
/// `endIndex`.
290
290
/// - Returns: The index immediately after `i`.
291
- @available ( SwiftStdlib 6 . 1 , * )
291
+ @available ( SwiftStdlib 6 . 2 , * )
292
292
@_alwaysEmitIntoClient
293
293
@_transparent
294
294
public borrowing func index( after i: Int ) -> Int {
@@ -300,7 +300,7 @@ extension Slab where Element: ~Copyable {
300
300
/// - Parameter i: A valid index of the collection. `i` must be greater than
301
301
/// `startIndex`.
302
302
/// - Returns: The index value immediately before `i`.
303
- @available ( SwiftStdlib 6 . 1 , * )
303
+ @available ( SwiftStdlib 6 . 2 , * )
304
304
@_alwaysEmitIntoClient
305
305
@_transparent
306
306
public borrowing func index( before i: Int ) -> Int {
@@ -326,7 +326,7 @@ extension Slab where Element: ~Copyable {
326
326
/// `endIndex` property.
327
327
///
328
328
/// - Complexity: O(1)
329
- @available ( SwiftStdlib 6 . 1 , * )
329
+ @available ( SwiftStdlib 6 . 2 , * )
330
330
@_addressableSelf
331
331
@_alwaysEmitIntoClient
332
332
public subscript( _ i: Int ) -> Element {
@@ -350,7 +350,7 @@ extension Slab where Element: ~Copyable {
350
350
// Swap
351
351
//===----------------------------------------------------------------------===//
352
352
353
- @available ( SwiftStdlib 6 . 1 , * )
353
+ @available ( SwiftStdlib 6 . 2 , * )
354
354
extension Slab where Element: ~ Copyable {
355
355
/// Exchanges the values at the specified indices of the vector.
356
356
///
@@ -363,7 +363,7 @@ extension Slab where Element: ~Copyable {
363
363
/// - j: The index of the second value to swap.
364
364
///
365
365
/// - Complexity: O(1)
366
- @available ( SwiftStdlib 6 . 1 , * )
366
+ @available ( SwiftStdlib 6 . 2 , * )
367
367
@_alwaysEmitIntoClient
368
368
public mutating func swapAt(
369
369
_ i: Int ,
@@ -387,7 +387,7 @@ extension Slab where Element: ~Copyable {
387
387
// Unsafe APIs
388
388
//===----------------------------------------------------------------------===//
389
389
390
- @available ( SwiftStdlib 6 . 1 , * )
390
+ @available ( SwiftStdlib 6 . 2 , * )
391
391
extension Slab where Element: ~ Copyable {
392
392
/// Calls a closure with a pointer to the vector's contiguous storage.
393
393
///
@@ -422,7 +422,7 @@ extension Slab where Element: ~Copyable {
422
422
/// `withUnsafeBufferPointer(_:)` method. The pointer argument is valid only
423
423
/// for the duration of the method's execution.
424
424
/// - Returns: The return value, if any, of the `body` closure parameter.
425
- @available ( SwiftStdlib 6 . 1 , * )
425
+ @available ( SwiftStdlib 6 . 2 , * )
426
426
@_alwaysEmitIntoClient
427
427
@_transparent
428
428
public borrowing func _withUnsafeBufferPointer< Result: ~ Copyable, E: Error > (
@@ -471,7 +471,7 @@ extension Slab where Element: ~Copyable {
471
471
/// for the `withUnsafeMutableBufferPointer(_:)` method. The pointer
472
472
/// argument is valid only for the duration of the method's execution.
473
473
/// - Returns: The return value, if any, of the `body` closure parameter.
474
- @available ( SwiftStdlib 6 . 1 , * )
474
+ @available ( SwiftStdlib 6 . 2 , * )
475
475
@_alwaysEmitIntoClient
476
476
@_transparent
477
477
public mutating func _withUnsafeMutableBufferPointer< Result: ~ Copyable, E: Error > (
0 commit comments