Generic Instance Method

withContiguousStorageIfAvailable(_:)

Call body(p), where p is a pointer to the collection’s contiguous storage. If no such storage exists, it is first created. If the collection does not support an internal representation in a form of contiguous storage, body is not called and nil is returned.

Declaration

func withContiguousStorageIfAvailable<R>(_ body: (UnsafeBufferPointer<Bound>) throws -> R) rethrows -> R?
Available when Bound conforms to Strideable and Bound.Stride conforms to SignedInteger.

Discussion

A Collection that provides its own implementation of this method must also guarantee that an equivalent buffer of its SubSequence can be generated by advancing the pointer by the distance to the slice’s startIndex.

See Also

Infrequently Used Functionality

func index(of: Bound) -> Bound?

Returns the first index where the specified value appears in the collection.

Deprecated
init(uncheckedBounds: (lower: Bound, upper: Bound))

Creates an instance with the given bounds.