MutableCollection

extension MutableCollection
extension MutableCollection where Self: BidirectionalCollection
extension MutableCollection where Self: RandomAccessCollection
  • Rotates the elements of the collection so that the element at middle ends up first.

    Complexity

    O(n)

    Declaration

    @discardableResult
    public mutating mutating func rotate(shiftingToStart middle: Index) -> Index

    Return Value

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

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

    Complexity

    O(n)

    Declaration

    @discardableResult
    public mutating mutating func rotate(shiftingToStart middle: Index) -> Index

    Return Value

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

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

    Complexity

    O(n)

    Declaration

    @discardableResult
    public mutating func rotateRandomAccess(
      shiftingToStart middle: Index
    ) -> Index

    Return Value

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