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

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/UnsafeMutableBufferPointer/partition(by:)-90pnv)

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 reverse()`](/documentation/Swift/UnsafeMutableBufferPointer/reverse())

Reverses the elements of the collection in place.

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

Shuffles the collection in place.

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

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

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

Sorts the collection in place.

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

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

[`func swapAt(Int, Int)`](/documentation/Swift/UnsafeMutableBufferPointer/swapAt(_:_:))

Exchanges the values at the specified indices of the buffer.

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

Executes a closure on the collection’s contiguous storage.

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

Executes a closure on the collection’s contiguous storage.

---

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)