Inserts the elements of a sequence into the collection at the specified position.
- Xcode 9.0+
- Swift Standard Library
The new elements to insert into the collection.
The position at which to insert the new elements.
indexmust be a valid index of the collection.
The new elements are inserted before the element currently at the specified index. If you pass the collection’s
end property as the
index parameter, the new elements are appended to the collection.
Here’s an example of inserting a range of integers into an array of the same type:
Calling this method may invalidate any existing indices for use with this collection.
Complexity: O(m), where m is the combined length of the collection and
i is equal to the collection’s
end property, the complexity is O(n), where n is the length of