Generic Instance Method

replaceSubrange(_:with:)

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

Declaration

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

Parameters

subrange

The range in the data to replace.

buffer

The replacement bytes.

Discussion

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

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

See Also

Replacing a Range of Bytes

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

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

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

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

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

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