<!--
{
  "documentType" : "article",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/ContiguousArray/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/ContiguousArray/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/ContiguousArray/partition(by:)-2g3t0)

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/ContiguousArray/partition(by:)-2uabq)

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/ContiguousArray/removeSubranges(_:)-5ci4m)

Removes the elements at the given indices.

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

Reverses the elements of the collection in place.

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

Shuffles the collection in place.

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

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

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

Sorts the collection in place.

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

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

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

Exchanges the values at the specified indices of the collection.

[`func withContiguousMutableStorageIfAvailable<R>((inout UnsafeMutableBufferPointer<Element>) throws -> R) rethrows -> R?`](/documentation/Swift/ContiguousArray/withContiguousMutableStorageIfAvailable(_:))

Executes a closure on the collection’s contiguous storage.

[`func withContiguousMutableStorageIfAvailable<R>((inout UnsafeMutableBufferPointer<Self.Element>) throws -> R) rethrows -> R?`](/documentation/Swift/ContiguousArray/withContiguousMutableStorageIfAvailable(_:)-5k8vo)

Executes a closure on the collection’s contiguous storage.

### Subscripts

[`subscript(UnboundedRange) -> Self.SubSequence`](/documentation/Swift/ContiguousArray/subscript(_:)-17v9t)

[`subscript(Range<Self.Index>) -> Self.SubSequence`](/documentation/Swift/ContiguousArray/subscript(_:)-27a3j)

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

Accesses a contiguous subrange of the collection’s elements.

[`subscript<R>(R) -> Self.SubSequence`](/documentation/Swift/ContiguousArray/subscript(_:)-7ribf)

---

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)