<!--
{
  "documentType" : "article",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Unicode/Scalar/UTF16View/RandomAccessCollection-Implementations",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "RandomAccessCollection Implementations"
}
-->

# RandomAccessCollection Implementations

## Topics

### Instance Properties

[`var endIndex: Int`](/documentation/Swift/Unicode/Scalar/UTF16View/endIndex)

The “past the end” position—that is, the position one
greater than the last valid subscript argument.

[`var indices: Range<Self.Index>`](/documentation/Swift/Unicode/Scalar/UTF16View/indices-swift.property)

The indices that are valid for subscripting the collection, in ascending
order.

[`var startIndex: Int`](/documentation/Swift/Unicode/Scalar/UTF16View/startIndex)

The position of the first code unit.

### Instance Methods

[`func distance(from: Self.Index, to: Self.Index) -> Self.Index.Stride`](/documentation/Swift/Unicode/Scalar/UTF16View/distance(from:to:))

Returns the distance between two indices.

[`func index(Self.Index, offsetBy: Self.Index.Stride) -> Self.Index`](/documentation/Swift/Unicode/Scalar/UTF16View/index(_:offsetBy:))

Returns an index that is the specified distance from the given index.

[`func index(Self.Index, offsetBy: Int, limitedBy: Self.Index) -> Self.Index?`](/documentation/Swift/Unicode/Scalar/UTF16View/index(_:offsetBy:limitedBy:))

Returns an index that is the specified distance from the given index,
unless that distance is beyond a given limiting index.

[`func index(after: Self.Index) -> Self.Index`](/documentation/Swift/Unicode/Scalar/UTF16View/index(after:))

Returns the position immediately after the given index.

[`func index(before: Self.Index) -> Self.Index`](/documentation/Swift/Unicode/Scalar/UTF16View/index(before:))

Returns the position immediately after the given index.

### Subscripts

[`subscript(Int) -> UTF16.CodeUnit`](/documentation/Swift/Unicode/Scalar/UTF16View/subscript(_:))

Accesses the code unit at the specified position.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)