mirror of
https://github.com/apple/swift-collections
synced 2026-11-25 04:37:48 +00:00
55 lines
1.9 KiB
Swift
55 lines
1.9 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift Collections open source project
|
|
//
|
|
// Copyright (c) 2025 - 2026 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0 WITH Swift-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#if !COLLECTIONS_SINGLE_MODULE
|
|
import InternalCollectionsUtilities
|
|
#endif
|
|
|
|
// This file contains exported but non-public entry points to support clear box
|
|
// testing.
|
|
|
|
@available(SwiftStdlib 5.0, *)
|
|
extension RigidDeque where Element: ~Copyable {
|
|
/// The number of the storage slot in this deque that holds the first element.
|
|
/// (Or would hold it after an insertion in case the deque is currently
|
|
/// empty.)
|
|
///
|
|
/// This property isn't intended to be used outside of `DequeModule`'s own test
|
|
/// target.
|
|
@_alwaysEmitIntoClient
|
|
package var _startSlot: Int {
|
|
unsafe _handle.startSlot.position
|
|
}
|
|
}
|
|
|
|
@available(SwiftStdlib 5.0, *)
|
|
extension RigidDeque where Element: ~Copyable {
|
|
/// Constructs a deque instance of the specified contents and layout. Exposed
|
|
/// as public to allow exhaustive input/output tests for `RigidDeque` members.
|
|
///
|
|
/// This initializer isn't intended to be used outside of `DequeModule`'s
|
|
/// own test target.
|
|
@_alwaysEmitIntoClient
|
|
package init(
|
|
_capacity capacity: Int,
|
|
startSlot: Int,
|
|
initializingWith initializer: (inout OutputSpan<Element>) -> Void
|
|
) {
|
|
self.init(capacity: capacity)
|
|
unsafe _handle._startSlot = _handle.slot(_handle.startSlot, offsetBy: startSlot)
|
|
self.append(addingCount: capacity, initializingWith: initializer)
|
|
assert(self.capacity == capacity)
|
|
assert(self._startSlot == startSlot)
|
|
}
|
|
}
|