public protocol MutableCollectionAlgorithms: MutableCollection
where SubSequence: MutableCollectionAlgorithms

Provides customization points for MutableCollection algorithms.

If incorporated into the standard library, these requirements would just be part of MutableCollection. In the meantime, you can declare conformance of a collection to MutableCollectionAlgorithms to get these customization points to be used from other algorithms defined on MutableCollectionAlgorithms.

  • Rotates the elements of the collection so that the element at middle ends up first.




    mutating mutating func rotate(shiftingToStart middle: Index) -> Index

    Return Value

    The new index of the element that was first pre-rotation.

  • Moves all elements satisfying isSuffixElement into a suffix of the collection, preserving their relative order, and returns the start of the resulting suffix.


    O(n) where n is the number of elements.


    mutating func stablePartition(
      isSuffixElement: (Element) throws -> Bool
    ) rethrows -> Index