Contents

setCapacity(_:)

Grow or shrink the capacity of a unique array instance without discarding its contents.

Declaration

mutating func setCapacity(_ newCapacity: Int)

Discussion

This operation replaces the array’s storage buffer with a newly allocated buffer of the specified capacity, moving all existing elements to its new storage. The old storage is then deallocated.