maximumCount → maxCount

While we’re here, adjust `RigidSet.insert(maximumCount:initializingWith:)` and similar APIs to be consistent with RangeReplaceableContainer’s methods.
This commit is contained in:
Karoy Lorentey committed 2026-07-07 14:21:53 -07:00
1 parent 72c0dd258d
commit bb0dc189ef
64 files changed
+505 -275

No files matched your search

@@ -284,7 +284,7 @@ extension UniqueArray where Element: ~Copyable {
/// Return a span over the array's storage that begins with the element at
/// the given index, and extends to the end of the contiguous storage chunk
/// that contains it, but no more than `maximumCount` items.
/// that contains it, but no more than `maxCount` items.
///
/// On return, the index is updated to address the next item following the
/// end of the returned span.
@@ -295,30 +295,30 @@ extension UniqueArray where Element: ~Copyable {
///
/// var index = items.startIndex
/// while true {
/// let span = items.nextSpan(after: &index, maximumCount: 4)
/// let span = items.nextSpan(after: &index, maxCount: 4)
/// if span.isEmpty { break }
/// // Process items in `span`
/// }
///
/// The `maximumCount` argument gives the caller control over the number of
/// The `maxCount` argument gives the caller control over the number of
/// items it receives from the iterator. This lets the caller avoid getting
/// more elements than it would be able to immediately process, which would
/// significantly complicate container use.
///
/// If the caller is able to process any number available items, it can signal
/// that by passing `Int.max` as the `maximumCount`, or simply by calling the
/// that by passing `Int.max` as the `maxCount`, or simply by calling the
/// `nexSpan(after:)` method, which does precisely that. This is frequently
/// the case when the caller simply wants to iterate over the entire
/// container in a single loop.
///
/// `maximumCount` sets an upper bound. To read a specific number of items,
/// `maxCount` sets an upper bound. To read a specific number of items,
/// the caller usually needs to invoke `nextSpan` in a loop:
///
/// var items: some Container<Int>
/// var index = items.startIndex
/// var remainder = numberOfItemsToRead
/// while remainder > 0 {
/// let next = items.nextSpan(after: &index, maximumCount: remainder)
/// let next = items.nextSpan(after: &index, maxCount: remainder)
/// guard !next.isEmpty else {
/// // Container does not have enough items
/// break
@@ -341,10 +341,10 @@ extension UniqueArray where Element: ~Copyable {
/// - Parameter index: A valid index in the container, including the end
/// index. On return, this index is advanced by the count of the resulting
/// span, to simplify iteration.
/// - Parameter maximumCount: The maximum number of items the caller is able
/// to process immediately. `maximumCount` must be greater than zero.
/// - Parameter maxCount: The maximum number of items the caller is able
/// to process immediately. `maxCount` must be greater than zero.
/// If you are able to process an arbitrary number of items, set
/// `maximumCount` to `Int.max`, or call the `nextSpan(after:)` method.
/// `maxCount` to `Int.max`, or call the `nextSpan(after:)` method.
/// - Returns: A span over contiguous storage that starts at the given index.
/// If the input index is the end index, then this returns an empty span.
/// Otherwise the result is non-empty, with its first element matching the
@@ -353,25 +353,25 @@ extension UniqueArray where Element: ~Copyable {
@inlinable
@_lifetime(borrow self)
public func nextSpan(
after index: inout Int, maximumCount: Int
after index: inout Int, maxCount: Int
) -> Span<Element> {
_storage.nextSpan(after: &index, maximumCount: maximumCount)
_storage.nextSpan(after: &index, maxCount: maxCount)
}
@inlinable
@_lifetime(&self)
public mutating func nextMutableSpan(
after index: inout Int, maximumCount: Int
after index: inout Int, maxCount: Int
) -> MutableSpan<Element> {
_storage.nextMutableSpan(after: &index, maximumCount: maximumCount)
_storage.nextMutableSpan(after: &index, maxCount: maxCount)
}
@inlinable
@_lifetime(borrow self)
public func previousSpan(
before index: inout Int, maximumCount: Int
before index: inout Int, maxCount: Int
) -> Span<Element> {
_storage.previousSpan(before: &index, maximumCount: maximumCount)
_storage.previousSpan(before: &index, maxCount: maxCount)
}
}
@@ -15,6 +15,33 @@
@available(SwiftStdlib 5.0, *)
extension UniqueArray where Element: ~Copyable {
@available(*, deprecated, renamed: "nextSpan(after:maxCount:)")
@inlinable
@_lifetime(borrow self)
public func nextSpan(
after index: inout Int, maximumCount: Int
) -> Span<Element> {
self.nextSpan(after: &index, maxCount: maximumCount)
}
@available(*, deprecated, renamed: "nextMutableSpan(after:maxCount:)")
@inlinable
@_lifetime(&self)
public mutating func nextMutableSpan(
after index: inout Int, maximumCount: Int
) -> MutableSpan<Element> {
self.nextMutableSpan(after: &index, maxCount: maximumCount)
}
@available(*, deprecated, renamed: "previousSpan(before:maxCount:)")
@inlinable
@_lifetime(borrow self)
public func previousSpan(
before index: inout Int, maximumCount: Int
) -> Span<Element> {
self.previousSpan(before: &index, maxCount: maximumCount)
}
/// Initializes a new unique array with the specified capacity and no elements.
@available(*, deprecated, renamed: "init(minimumCapacity:)")
@inlinable
@@ -346,7 +346,7 @@ extension UniqueArray where Element: ~Copyable {
@available(SwiftStdlib 5.0, *)
extension UniqueArray where Element: ~Copyable {
#if compiler(>=6.4) && UnstableContainersPreview
/// Replaces the specified range of elements by at most `maximumCount` items
/// Replaces the specified range of elements by at most `maxCount` items
/// generated by a producer.
///
/// This method has the effect of removing the specified range of elements
@@ -367,8 +367,8 @@ extension UniqueArray where Element: ~Copyable {
/// directly expressed by calling `removeSubrange`.
///
/// This operation inserts as many items as the producer can generate before
/// either reaching `maximumCount`, or the producer hitting its end, or
/// throwing an error. If the producer has more than `maximumCount` items left in
/// either reaching `maxCount`, or the producer hitting its end, or
/// throwing an error. If the producer has more than `maxCount` items left in
/// its underlying sequence, then extra items remain available after this
/// method returns.
///