<!--
{
  "documentType" : "article",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Slice/MutableCollection-Implementations",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "MutableCollection Implementations"
}
-->

# MutableCollection Implementations

## Topics

### Instance Methods

[`func moveSubranges(RangeSet<Self.Index>, to: Self.Index) -> Range<Self.Index>`](/documentation/Swift/Slice/moveSubranges(_:to:))

Moves the elements in the given subranges to just before the element at
the specified index.

[`func partition(by: (Self.Element) throws -> Bool) rethrows -> Self.Index`](/documentation/Swift/Slice/partition(by:)-7efo8)

Reorders the elements of the collection such that all the elements
that match the given predicate are after all the elements that don’t
match.

[`func partition(by: (Self.Element) throws -> Bool) rethrows -> Self.Index`](/documentation/Swift/Slice/partition(by:)-7n9yj)

Reorders the elements of the collection such that all the elements
that match the given predicate are after all the elements that don’t
match.

[`func removeSubranges(RangeSet<Self.Index>)`](/documentation/Swift/Slice/removeSubranges(_:)-20t3r)

Removes the elements at the given indices.

[`func reverse()`](/documentation/Swift/Slice/reverse())

Reverses the elements of the collection in place.

[`func shuffle()`](/documentation/Swift/Slice/shuffle())

Shuffles the collection in place.

[`func shuffle<T>(using: inout T)`](/documentation/Swift/Slice/shuffle(using:))

Shuffles the collection in place, using the given generator as a source
for randomness.

[`func sort()`](/documentation/Swift/Slice/sort())

Sorts the collection in place.

[`func sort(by: (Self.Element, Self.Element) throws -> Bool) rethrows`](/documentation/Swift/Slice/sort(by:))

Sorts the collection in place, using the given predicate as the
comparison between elements.

[`func swapAt(Self.Index, Self.Index)`](/documentation/Swift/Slice/swapAt(_:_:))

Exchanges the values at the specified indices of the collection.

[`func withContiguousMutableStorageIfAvailable<R>((inout UnsafeMutableBufferPointer<Slice<Base>.Element>) throws -> R) rethrows -> R?`](/documentation/Swift/Slice/withContiguousMutableStorageIfAvailable(_:)-2ual)

Executes a closure on the collection’s contiguous storage.

### Subscripts

[`subscript(Range<Self.Index>) -> Self.SubSequence`](/documentation/Swift/Slice/subscript(_:)-2elba)

[`subscript(UnboundedRange) -> Self.SubSequence`](/documentation/Swift/Slice/subscript(_:)-3p9dc)

[`subscript<R>(R) -> Self.SubSequence`](/documentation/Swift/Slice/subscript(_:)-4f8ky)

[`subscript(Range<Slice<Base>.Index>) -> Slice<Base>`](/documentation/Swift/Slice/subscript(_:)-87kqd)

Accesses a contiguous subrange of the collection’s elements.

[`subscript(Range<Self.Index>) -> Slice<Self>`](/documentation/Swift/Slice/subscript(_:)-8pq5s)

Accesses a contiguous subrange of the collection’s elements.

[`subscript(Range<Self.Index>) -> Slice<Self>`](/documentation/Swift/Slice/subscript(_:)-uq47)

Accesses a contiguous subrange of the collection’s elements.

[`subscript(Slice<Base>.Index) -> Base.Element`](/documentation/Swift/Slice/subscript(_:)-z7ny)

Accesses the element at the specified position.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)