Instance Method

replaceSubrange(_:with:)

Replaces a region of bytes in the data with new data.

Declaration

mutating func replaceSubrange(_ subrange: Range<Data.Index>, with data: Data)

Parameters

subrange

The range in the data to replace. If subrange.lowerBound == data.count && subrange.count == 0 then this operation is an append.

data

The replacement data.

Discussion

This will resize the data if required, to fit the entire contents of data.

Precondition: The bounds of subrange must be valid indices of the collection.

See Also

Replacing a Range of Bytes

func replaceSubrange<ByteCollection>(Range<Data.Index>, with: ByteCollection)

Replaces a region of bytes in the data with new bytes from a collection.

func replaceSubrange<SourceType>(Range<Data.Index>, with: UnsafeBufferPointer<SourceType>)

Replaces a region of bytes in the data with new bytes from a buffer.

func replaceSubrange(Range<Data.Index>, with: UnsafeRawPointer, count: Int)

Replaces a region of bytes in the data with bytes from memory.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software