Instance Method

reserveCapacity(_:)

Prepares the collection to store the specified number of elements, when doing so is appropriate for the underlying type.

Declaration

mutating func reserveCapacity(_ minimumCapacity: Int)

Parameters

n

The requested number of elements to store.

Discussion

If you will be adding a known number of elements to a collection, use this method to avoid multiple reallocations. A type that conforms to RangeReplaceableCollection can choose how to respond when this method is called. Depending on the type, it may make sense to allocate more or less storage than requested or to take no action at all.

Relationships

See Also

Adding Bytes

func append(Data)

Appends the specified data to the end of this data.

func append(UnsafePointer<UInt8>, count: Int)

Appends the specified bytes from memory to the end of the data.

func append(contentsOf: [UInt8])

Appends the bytes in the specified array to the end of the data.