Exchanges the values at the specified indices of the collection.
SDK
- Xcode 9.0+
Framework
- Swift Standard Library
Declaration
Parameters
iThe index of the first value to swap.
jThe index of the second value to swap.
Discussion
Both parameters must be valid indices of the collection that are not equal to end. Calling swap with the same index as both i and j has no effect.
Complexity: O(1)