Generic Instance Method

replaceSubrange(_:with:)

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

Declaration

mutating func replaceSubrange<ByteCollection>(_ subrange: Range<Data.Index>, with newElements: ByteCollection) where ByteCollection : Collection, ByteCollection.Element == Data.Iterator.Element

Parameters

subrange

The range in the data to replace.

newElements

The replacement bytes.

Discussion

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

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

Relationships

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<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