mirror of
https://github.com/apple/swift-collections
synced 2026-11-29 05:14:20 +00:00
Review RigidDeque/UniqueDeque tests; add better tests for prepends
This commit is contained in:
10 files changed
+779
-260
No files matched your search
@@ -33,7 +33,7 @@ extension RigidDeque where Element: ~Copyable {
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension RigidDeque {
|
||||
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.
|
||||
///
|
||||
@@ -43,15 +43,12 @@ extension RigidDeque {
|
||||
package init(
|
||||
_capacity capacity: Int,
|
||||
startSlot: Int,
|
||||
copying contents: some Sequence<Element>
|
||||
initializingWith initializer: (inout OutputSpan<Element>) -> Void
|
||||
) {
|
||||
let contents = Array(contents)
|
||||
|
||||
self.init(capacity: capacity)
|
||||
unsafe _handle._startSlot = _handle.slot(_handle.startSlot, offsetBy: startSlot)
|
||||
self.append(copying: contents)
|
||||
self.append(addingCount: capacity, initializingWith: initializer)
|
||||
assert(self.capacity == capacity)
|
||||
assert(self._startSlot == startSlot)
|
||||
assert(self.count == contents.count)
|
||||
}
|
||||
}
|
||||
@@ -362,6 +362,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
/// invocations on the same deque.
|
||||
@inlinable
|
||||
@_alwaysEmitIntoClient
|
||||
@discardableResult
|
||||
public mutating func prepend(
|
||||
copying items: some Collection<Element>
|
||||
) -> Range<Int> {
|
||||
|
||||
Reference in new issue
Block a user