Exchanges the values at the specified indices of the collection.
Required. Default implementation provided.
SDK
- Xcode 10.0+
Framework
- Swift Standard Library
Declaration
Parameters
i
The index of the first value to swap.
j
The index of the second value to swap.
Discussion
Both parameters must be valid indices of the collection and not equal to end
. Passing the same index as both i
and j
has no effect.
Complexity: O(1)