mirror of
https://github.com/apple/swift-collections
synced 2026-11-25 04:37:48 +00:00
[BasicContainers] RigidArray, UniqueArray: “precisely once” → “at most once”
Loosen guarantees about how many times closure arguments are getting called, so that e.g. insertions of zero items do not necessarily need to call their callback with an empty OutputSpan. (For these array types we can reinstate the guarantee later, if it turns out to be important/useful. However, the generalized primitives will need to allow their callbacks to get called an arbitrary number of times, and it seems useful to establish that (at least partially) with these simple array types too.)
This commit is contained in:
11 files changed
+18
-14
No files matched your search
@@ -128,7 +128,7 @@ extension UniqueArray where Element: ~Copyable {
|
||||
extension UniqueArray where Element: ~Copyable {
|
||||
/// Arbitrarily edit the storage underlying this array by invoking a
|
||||
/// user-supplied closure with a mutable `OutputSpan` view over it.
|
||||
/// This method calls its function argument precisely once, allowing it to
|
||||
/// This method calls its function argument at most once, allowing it to
|
||||
/// arbitrarily modify the contents of the output span it is given.
|
||||
/// The argument is free to add, remove or reorder any items; however,
|
||||
/// it is not allowed to replace the span or change its capacity.
|
||||
@@ -139,7 +139,7 @@ extension UniqueArray where Element: ~Copyable {
|
||||
///
|
||||
/// - Parameter body: A function that edits the contents of this array through
|
||||
/// an `OutputSpan` argument. This method invokes this function
|
||||
/// precisely once.
|
||||
/// at most once.
|
||||
/// - Returns: This method returns the result of its function argument.
|
||||
/// - Complexity: Adds O(1) overhead to the complexity of the function
|
||||
/// argument.
|
||||
|
||||
Reference in new issue
Block a user