@@ -172,34 +172,53 @@ where SubSequence: MutableCollection
172172 ///
173173 /// - Complexity: O(1)
174174 mutating func swapAt( _ i: Index , _ j: Index )
175-
176- /// Call `body(p )`, where `p` is a pointer to the collection's
177- /// mutable contiguous storage. If no such storage exists, it is
178- /// first created. If the collection does not support an internal
179- /// representation in a form of mutable contiguous storage, `body` is not
175+
176+ /// Call `body(buffer )`, where `buffer` provides access to the contiguous
177+ /// mutable storage of the entire collection. If no such storage exists, it is
178+ /// first created. If the collection does not support an internal
179+ /// representation in the form of contiguous mutable storage, `body` is not
180180 /// called and `nil` is returned.
181181 ///
182- /// Often, the optimizer can eliminate bounds- and uniqueness-checks
183- /// within an algorithm, but when that fails, invoking the
184- /// same algorithm on `body`\ 's argument lets you trade safety for
185- /// speed.
182+ /// The optimizer can often eliminate bounds- and uniqueness-checking
183+ /// within an algorithm. When that fails, however, invoking the same
184+ /// algorithm on `body`\ 's argument may let you trade safety for speed.
185+ ///
186+ /// A `Collection` that provides its own implementation of this method
187+ /// must provide contiguous storage to its elements in the same order
188+ /// as they appear in the collection. This guarantees that contiguous
189+ /// mutable storage to any of its subsequences can be generated by slicing
190+ /// `buffer` with a range formed from the distances to the subsequence's
191+ /// `startIndex` and `endIndex`, respectively.
186192 @available ( * , deprecated, renamed: " withContiguousMutableStorageIfAvailable " )
187193 mutating func _withUnsafeMutableBufferPointerIfSupported< R> (
188194 _ body: ( inout UnsafeMutableBufferPointer < Element > ) throws -> R
189195 ) rethrows -> R ?
190196
191- /// Call `body(p )`, where `p` is a pointer to the collection's
192- /// mutable contiguous storage. If no such storage exists, it is
193- /// first created. If the collection does not support an internal
194- /// representation in a form of mutable contiguous storage, `body` is not
197+ /// Call `body(buffer )`, where `buffer` provides access to the contiguous
198+ /// mutable storage of the entire collection. If no such storage exists, it is
199+ /// first created. If the collection does not support an internal
200+ /// representation in the form of contiguous mutable storage, `body` is not
195201 /// called and `nil` is returned.
196202 ///
197- /// Often, the optimizer can eliminate bounds- and uniqueness-checks
198- /// within an algorithm, but when that fails, invoking the
199- /// same algorithm on `body`\ 's argument lets you trade safety for
200- /// speed.
203+ /// The optimizer can often eliminate bounds- and uniqueness-checking
204+ /// within an algorithm. When that fails, however, invoking the same
205+ /// algorithm on `body`\ 's argument may let you trade safety for speed.
206+ ///
207+ /// A `Collection` that provides its own implementation of this method
208+ /// must provide contiguous storage to its elements in the same order
209+ /// as they appear in the collection. This guarantees that contiguous
210+ /// mutable storage to any of its subsequences can be generated by slicing
211+ /// `buffer` with a range formed from the distances to the subsequence's
212+ /// `startIndex` and `endIndex`, respectively.
213+ ///
214+ /// - Note: `buffer` must not be replaced by `body`.
215+ ///
216+ /// - Parameters:
217+ /// - body: a closure to be executed using the elements of this collection.
218+ /// - buffer: a buffer to the mutable contiguous storage of this collection.
219+ /// - Returns: the value returned by `body`, or `nil`.
201220 mutating func withContiguousMutableStorageIfAvailable< R> (
202- _ body: ( inout UnsafeMutableBufferPointer < Element > ) throws -> R
221+ _ body: ( _ buffer : inout UnsafeMutableBufferPointer < Element > ) throws -> R
203222 ) rethrows -> R ?
204223}
205224
0 commit comments