mirror of
https://github.com/apple/swift-collections
synced 2026-11-27 04:54:21 +00:00
Review and update container protocols and conformances
- @inlinable → @_alwaysEmitIntoClient for now, to avoid temporary ABI issues
- Review RangeReplaceableContainer algorithms; add missing ones:
- New requirements: `removeFirst()`, `removeFirst(_:)`, `_customRemoveLast()`, `_customRemoveLast(_:) (with default implementations)
- `func removeAll()`
- `func removeLast()`, `func removeLast(_:)`, `func popLast()` when self is also bidirectional
- Review RigidArray, UniqueArray algorithms; remove ones needlessly duplicating functionality already provided by RRC. Try not to break source compatibility.
This commit is contained in:
36 files changed
+415
-644
No files matched your search
@@ -103,13 +103,14 @@ extension UniqueArray where Element: ~Copyable {
|
||||
/// - Complexity: O(`self.count`)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func removeSubrange(_ bounds: some RangeExpression<Int>) {
|
||||
// FIXME: Remove this in favor of a standard algorithm.
|
||||
// FIXME: Remove this in favor of the RangeReplaceableContainer algorithm.
|
||||
removeSubrange(bounds.relative(to: indices))
|
||||
}
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension UniqueArray where Element: ~Copyable {
|
||||
#if !UnstableContainersPreview
|
||||
/// Removes and returns the last element of the array, if there is one.
|
||||
///
|
||||
/// - Returns: The last element of the array if the array is not empty;
|
||||
@@ -118,9 +119,11 @@ extension UniqueArray where Element: ~Copyable {
|
||||
/// - Complexity: O(1)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func popLast() -> Element? {
|
||||
// FIXME: Remove this in favor of the RangeReplaceableContainer algorithm.
|
||||
if isEmpty { return nil }
|
||||
return removeLast()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user