diff --git a/Documentation/Container-design.md b/Documentation/Container-design.md index 1f926043..76345d45 100644 --- a/Documentation/Container-design.md +++ b/Documentation/Container-design.md @@ -456,7 +456,7 @@ Notably, we replace `Collection`'s classic `index(_:offsetBy:limitedBy:)` requir -The `limit` argument here (and also elsewhere throughout the `Container` interface surface) means a **limiting index**, intended to cause the operation to stop if it encounters the limit during its execution. A limit of this sort only triggers a stop if the operation needs to actively iterate over it. A limit that the operation never needs to visit has no effect, whether it happens to address a position before or after the visited range. For example, if we're trying to find the index by offseting position 10 by 5 places forward, a limiting index at position 3 has no effect -- to offset the original position, we only need to visit positions 10, 11, 12, 13, 14, and 15. +The `limit` argument here (and also elsewhere throughout the `Container` interface surface) means a **limiting index**, intended to cause the operation to stop if it encounters the limit during its execution. A limit of this sort only triggers a stop if the operation needs to actively iterate over it. A limit that the operation never needs to visit has no effect, whether it happens to address a position before or after the visited range. For example, if we're trying to find the index by offsetting position 10 by 5 places forward, a limiting index at position 3 has no effect -- to offset the original position, we only need to visit positions 10, 11, 12, 13, 14, and 15. These curious semantics allow types that cannot provide comparable indices to still correctly conform to the protocol. (For example, linked lists usually cannot determine relative ordering between their indices without actively iterating through the list in linear time. If `limit` was required to be observed even if it lied behind the starting position, then linked lists would need to painstakingly figure out if this was the case, by iterating through items we wouldn't expect the operation to ever visit.) @@ -1113,7 +1113,7 @@ Based on our expectations for predictably good container performance, we believe ## Mutable Containers -It is relatively straightforward to augment our read-only container model with new operations that allow in-place mutations. We'll follow in the footsteps of `MutableCollection` by defining a `MutableContainer` protocol. However, we carve it into two separate levels, by first introducing an intermediate protocol that forcuses on reordering. +It is relatively straightforward to augment our read-only container model with new operations that allow in-place mutations. We'll follow in the footsteps of `MutableCollection` by defining a `MutableContainer` protocol. However, we carve it into two separate levels, by first introducing an intermediate protocol that focuses on reordering. ### `protocol PermutableContainer` @@ -1393,7 +1393,7 @@ The ownership of all generated elements is transferred to the caller of this met -The `generate(into:)` operation may throw an error if it encounters an issue while trying to generate the upcoming next item in the sequence. Failure may happen midway through populating `target`, in which case the output span will still gain new items, despite the error. (Those items have been successfully generated, and do not necessarilly need to be discarded.) +The `generate(into:)` operation may throw an error if it encounters an issue while trying to generate the upcoming next item in the sequence. Failure may happen midway through populating `target`, in which case the output span will still gain new items, despite the error. (Those items have been successfully generated, and do not necessarily need to be discarded.) This protocol does not specify the meaning of a failure, or the precise state of the iterator after an error is thrown; however, the error must not trigger runtime traps in subsequent attempts at iteration. (After a failure, conforming types may choose to produce new items, or signal the end of the iteration, or throw another error, which may or may not match the first.) diff --git a/Sources/BasicContainers/BasicContainers.docc/BasicContainers.md b/Sources/BasicContainers/BasicContainers.docc/BasicContainers.md index d10b3606..9f1c2a36 100644 --- a/Sources/BasicContainers/BasicContainers.docc/BasicContainers.md +++ b/Sources/BasicContainers/BasicContainers.docc/BasicContainers.md @@ -54,7 +54,7 @@ Taking away the freedom to make implicit copies forces you to think a lot more a The name is apt -- that's quite inflexible behavior indeed. But sometimes this sort of inflexibility is exactly what we need! For instance, it makes it easy to ensure that the code we write will never use more memory than what we budgeted for it. -It also avoids wildly varying performance: in dynamically sized array types, `append` invocations usually have constant complexity, but once in a while they randomly spike to linear cost to resize the underlying storage. Of course, the use of a geometric growth strategy still allows the average complexity of an append operation to remain constant; but if a task must _always_ complete within a strict deadline, then statistical averages may not be good enough. Some engineers with a low-level mindset may choose to work within the constaints of carefully precalculated static capacities, and may prefer to consider it a hard fault if it is ever exceeded. +It also avoids wildly varying performance: in dynamically sized array types, `append` invocations usually have constant complexity, but once in a while they randomly spike to linear cost to resize the underlying storage. Of course, the use of a geometric growth strategy still allows the average complexity of an append operation to remain constant; but if a task must _always_ complete within a strict deadline, then statistical averages may not be good enough. Some engineers with a low-level mindset may choose to work within the constraints of carefully precalculated static capacities, and may prefer to consider it a hard fault if it is ever exceeded. Unlike ``InlineArray``, the capacity of a ``RigidArray`` is not part of its type declaration (nor its count) -- it is still a dynamic value. diff --git a/Sources/BasicContainers/HashTable/_HTable+Removal.swift b/Sources/BasicContainers/HashTable/_HTable+Removal.swift index 93f0ef0a..e2836207 100644 --- a/Sources/BasicContainers/HashTable/_HTable+Removal.swift +++ b/Sources/BasicContainers/HashTable/_HTable+Removal.swift @@ -15,7 +15,7 @@ extension _HTable { /// Create a hole at the specified occupied bucket without marking it as - /// unoccupied ot restoring the hash table's other invariants. After a hole + /// unoccupied or restoring the hash table's other invariants. After a hole /// is created, the table remains in an inconsistent state until one of /// `resolveHole` or `finalizeHole` is called on the same bucket. @usableFromInline diff --git a/Sources/BasicContainers/RigidArray/RigidArray+ContainerOperations.swift b/Sources/BasicContainers/RigidArray/RigidArray+ContainerOperations.swift index 90b17e05..51316e49 100644 --- a/Sources/BasicContainers/RigidArray/RigidArray+ContainerOperations.swift +++ b/Sources/BasicContainers/RigidArray/RigidArray+ContainerOperations.swift @@ -159,7 +159,7 @@ extension RigidArray where Element: ~Copyable { /// endIndex. Passing the same index as both `i` and `j` has no effect. /// /// - Parameter i: The index of the first value to swap. - /// - Parameter j: The index of the second valud to swap. + /// - Parameter j: The index of the second value to swap. /// /// - Complexity: O(1) @inlinable @@ -236,7 +236,7 @@ extension RigidArray where Element: ~Copyable { /// array. /// /// - Note: To improve performance, this method does not validate that the - /// given index is valid before offseting it. Index validation is + /// given index is valid before offsetting it. Index validation is /// deferred until the resulting index is used to access an element. /// This optimization may be removed in future versions; do not rely on it. /// @@ -256,7 +256,7 @@ extension RigidArray where Element: ~Copyable { /// Returns the distance between two indices. /// /// - Note: To improve performance, this method does not validate that the - /// given index is valid before offseting it. Index validation is + /// given index is valid before offsetting it. Index validation is /// deferred until the resulting index is used to access an element. /// This optimization may be removed in future versions; do not rely on it. /// @@ -287,7 +287,7 @@ extension RigidArray where Element: ~Copyable { /// those bounds. /// /// - Note: To improve performance, this method does not validate that the - /// given index is valid before offseting it. Index validation is + /// given index is valid before offsetting it. Index validation is /// deferred until the resulting index is used to access an element. /// This optimization may be removed in future versions; do not rely on it. /// diff --git a/Sources/BasicContainers/RigidArray/RigidArray.swift b/Sources/BasicContainers/RigidArray/RigidArray.swift index 0e391213..f3df6cd0 100644 --- a/Sources/BasicContainers/RigidArray/RigidArray.swift +++ b/Sources/BasicContainers/RigidArray/RigidArray.swift @@ -79,7 +79,7 @@ public struct RigidArray: ~Copyable { /// time-constrained applications that cannot accommodate unexpected latency /// spikes due to a reallocation getting triggered at an inopportune moment. /// -/// For use cases outside of these narrow domains, we generally recommmend +/// For use cases outside of these narrow domains, we generally recommend /// the use of ``UniqueArray`` rather than `RigidArray`. (For copyable elements, /// the standard `Array` is an even more convenient choice.) @available(SwiftStdlib 5.0, *) diff --git a/Sources/BasicContainers/UniqueArray/UniqueArray+ContainerOperations.swift b/Sources/BasicContainers/UniqueArray/UniqueArray+ContainerOperations.swift index ef168d66..86f09b23 100644 --- a/Sources/BasicContainers/UniqueArray/UniqueArray+ContainerOperations.swift +++ b/Sources/BasicContainers/UniqueArray/UniqueArray+ContainerOperations.swift @@ -115,7 +115,7 @@ extension UniqueArray where Element: ~Copyable { /// endIndex. Passing the same index as both `i` and `j` has no effect. /// /// - Parameter i: The index of the first value to swap. - /// - Parameter j: The index of the second valud to swap. + /// - Parameter j: The index of the second value to swap. /// /// - Complexity: O(1) @inlinable @@ -191,7 +191,7 @@ extension UniqueArray where Element: ~Copyable { /// array. /// /// - Note: To improve performance, this method does not validate that the - /// given index is valid before offseting it. Index validation is + /// given index is valid before offsetting it. Index validation is /// deferred until the resulting index is used to access an element. /// This optimization may be removed in future versions; do not rely on it. /// @@ -211,7 +211,7 @@ extension UniqueArray where Element: ~Copyable { /// Returns the distance between two indices. /// /// - Note: To improve performance, this method does not validate that the - /// given index is valid before offseting it. Index validation is + /// given index is valid before offsetting it. Index validation is /// deferred until the resulting index is used to access an element. /// This optimization may be removed in future versions; do not rely on it. /// @@ -242,7 +242,7 @@ extension UniqueArray where Element: ~Copyable { /// those bounds. /// /// - Note: To improve performance, this method does not validate that the - /// given index is valid before offseting it. Index validation is + /// given index is valid before offsetting it. Index validation is /// deferred until the resulting index is used to access an element. /// This optimization may be removed in future versions; do not rely on it. /// diff --git a/Sources/ContainersPreview/Protocols/Drain/Drain.swift b/Sources/ContainersPreview/Protocols/Drain/Drain.swift index 024ff09d..d25d6e9a 100644 --- a/Sources/ContainersPreview/Protocols/Drain/Drain.swift +++ b/Sources/ContainersPreview/Protocols/Drain/Drain.swift @@ -143,7 +143,7 @@ extension Drain where Self: ~Copyable & ~Escapable, Element: ~Copyable { /// the upcoming next item in the sequence. Failure may happen midway through /// populating `target`, in which case the output span will still gain /// new items despite the error. (Those items are successfully - /// generated, and do not necessarilly need to be discarded.) + /// generated, and do not necessarily need to be discarded.) /// /// This protocol does not specify the meaning of a failure, or the /// precise state of the iterator after an error is thrown; however, the diff --git a/Sources/ContainersPreview/Protocols/Producer/Producer.swift b/Sources/ContainersPreview/Protocols/Producer/Producer.swift index 453cda21..e6df4b7e 100644 --- a/Sources/ContainersPreview/Protocols/Producer/Producer.swift +++ b/Sources/ContainersPreview/Protocols/Producer/Producer.swift @@ -93,7 +93,7 @@ public protocol Producer: ~Copyable, ~Escapable { /// the upcoming next item in the sequence. Failure may happen midway through /// populating `target`, in which case the output span will still gain /// new items despite the error. (Those items are successfully - /// generated, and do not necessarilly need to be discarded.) + /// generated, and do not necessarily need to be discarded.) /// /// This protocol does not specify the meaning of a failure, or the /// precise state of the iterator after an error is thrown; however, the diff --git a/Sources/ContainersPreview/Types/UniqueBox.swift b/Sources/ContainersPreview/Types/UniqueBox.swift index 1ef213ad..6bf2ff4e 100644 --- a/Sources/ContainersPreview/Types/UniqueBox.swift +++ b/Sources/ContainersPreview/Types/UniqueBox.swift @@ -168,7 +168,7 @@ extension UniqueBox where Value: Copyable { value } - /// Copies the value within the unqiue box and returns it in a new unique + /// Copies the value within the unique box and returns it in a new unique /// instance. @_alwaysEmitIntoClient @_transparent diff --git a/Sources/DequeModule/RigidDeque/RigidDeque.swift b/Sources/DequeModule/RigidDeque/RigidDeque.swift index f740ab87..aefc8320 100644 --- a/Sources/DequeModule/RigidDeque/RigidDeque.swift +++ b/Sources/DequeModule/RigidDeque/RigidDeque.swift @@ -106,7 +106,7 @@ public struct RigidDeque: ~Copyable { /// time-constrained applications that cannot accommodate unexpected latency /// spikes due to a reallocation getting triggered at an inopportune moment. /// -/// For use cases outside of these narrow domains, we generally recommmend +/// For use cases outside of these narrow domains, we generally recommend /// to use the dynamically resizing ``UniqueDeque`` type rather than /// `RigidDeque`. For copyable elements, the copy-on-write `Deque` type is an /// even more convenient and expressive choice. @@ -308,7 +308,7 @@ extension RigidDeque where Element: ~Copyable { /// `endIndex`. Passing the same index as both `i` and `j` has no effect. /// /// - Parameter i: The index of the first value to swap. - /// - Parameter j: The index of the second valud to swap. + /// - Parameter j: The index of the second value to swap. /// /// - Complexity: O(1) @inlinable diff --git a/Sources/DequeModule/UniqueDeque/UniqueDeque.swift b/Sources/DequeModule/UniqueDeque/UniqueDeque.swift index 43db99d0..0dca4fe1 100644 --- a/Sources/DequeModule/UniqueDeque/UniqueDeque.swift +++ b/Sources/DequeModule/UniqueDeque/UniqueDeque.swift @@ -237,7 +237,7 @@ extension UniqueDeque where Element: ~Copyable { /// `endIndex`. Passing the same index as both `i` and `j` has no effect. /// /// - Parameter i: The index of the first value to swap. - /// - Parameter j: The index of the second valud to swap. + /// - Parameter j: The index of the second value to swap. /// /// - Complexity: O(1) @_transparent diff --git a/Sources/RopeModule/BigString/Views/BigSubstring.swift b/Sources/RopeModule/BigString/Views/BigSubstring.swift index 860717f2..af5eadc3 100644 --- a/Sources/RopeModule/BigString/Views/BigSubstring.swift +++ b/Sources/RopeModule/BigString/Views/BigSubstring.swift @@ -256,7 +256,7 @@ extension BigSubstring { // Substring mutations may change grapheme boundaries across the bounds of the original // substring value, and we need to ensure that the substring's bounds remain well-aligned. // Unfortunately, there are multiple ways of doing this, none of which are obviously - // superior to others. To keep the behavior easier to explan, we emulate substring + // superior to others. To keep the behavior easier to explain, we emulate substring // initialization and round the start and end indices down to the nearest Character boundary // after each mutation. let delta = self._base._utf8Count - oldCount diff --git a/Sources/SortedCollections/BTree/_Node.UnsafeHandle+Deletion.swift b/Sources/SortedCollections/BTree/_Node.UnsafeHandle+Deletion.swift index 9fcb7caa..d92ca110 100644 --- a/Sources/SortedCollections/BTree/_Node.UnsafeHandle+Deletion.swift +++ b/Sources/SortedCollections/BTree/_Node.UnsafeHandle+Deletion.swift @@ -366,7 +366,7 @@ extension _Node.UnsafeHandle { /// Collapses a slot and its children into a single child. /// - /// This will reuse the left childs node for the new node. As a result, ensure + /// This will reuse the left child's node for the new node. As a result, ensure /// that the left node is large enough to contain both the parent and the /// right child's contents, else this method may trap. /// diff --git a/Sources/SortedCollections/BTree/_Node.UnsafeHandle.swift b/Sources/SortedCollections/BTree/_Node.UnsafeHandle.swift index 7fae8b59..6b72fe92 100644 --- a/Sources/SortedCollections/BTree/_Node.UnsafeHandle.swift +++ b/Sources/SortedCollections/BTree/_Node.UnsafeHandle.swift @@ -73,7 +73,7 @@ extension _Node { #endif } - // MARK: Mutablility Checks + // MARK: Mutability Checks #if COLLECTIONS_INTERNAL_CHECKS @usableFromInline internal let _isMutable: Bool @@ -440,7 +440,7 @@ extension _Node.UnsafeHandle { /// - target: The destination handle to write to which could be the same /// as the source to move within a handle. /// - sourceSlot: The offset of the source handle to move from. - /// - destinationSlot: The offset of the destintion handle to write to. + /// - destinationSlot: The offset of the destination handle to write to. /// - count: The amount of values to move /// - Warning: This does not adjust the buffer counts. /// - Warning: This will trap if either the source and destination handles are leaves. diff --git a/Tests/_CollectionsTestSupport/ConformanceCheckers/CheckContainer.swift b/Tests/_CollectionsTestSupport/ConformanceCheckers/CheckContainer.swift index 0616fb02..8b1477da 100644 --- a/Tests/_CollectionsTestSupport/ConformanceCheckers/CheckContainer.swift +++ b/Tests/_CollectionsTestSupport/ConformanceCheckers/CheckContainer.swift @@ -473,7 +473,7 @@ public func validateContainer< } else { guard index == limit, n == delta - l + i else { throw ValidationError( - "`formIndex(_:offsetBy:limitedBy:)` must report partial succcess when the limit applies", + "`formIndex(_:offsetBy:limitedBy:)` must report partial success when the limit applies", ["input index": allIndices[i], "input delta": delta, "expected index": limit,