Instance Method

removeSubrange(_:)

Removes the specified subrange of elements from the collection.

Required. Default implementation provided.

Declaration

mutating func removeSubrange(_ bounds: Range<Self.Index>)

Parameters

bounds

The subrange of the collection to remove. The bounds of the range must be valid indices of the collection.

Discussion

var bugs = ["Aphid", "Bumblebee", "Cicada", "Damselfly", "Earwig"]
bugs.removeSubrange(1...3)
print(bugs)
// Prints "["Aphid", "Earwig"]"

Calling this method may invalidate any existing indices for use with this collection.

Complexity: O(n), where n is the length of the collection.

Default Implementations

RangeReplaceableCollection Implementations

func removeSubrange<R>(R)

Removes the elements in the specified subrange from the collection.

func removeSubrange(Range<Self.Index>)

Removes the elements in the specified subrange from the collection.