Contents

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