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

# RandomAccessCollection Implementations

## Topics

### Instance Properties

[`var endIndex: AnyRandomAccessCollection<Element>.Index`](/documentation/Swift/AnyRandomAccessCollection/endIndex)

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

[`var startIndex: AnyRandomAccessCollection<Element>.Index`](/documentation/Swift/AnyRandomAccessCollection/startIndex)

The position of the first element in a non-empty collection.

### Instance Methods

[`func distance(from: AnyRandomAccessCollection<Element>.Index, to: AnyRandomAccessCollection<Element>.Index) -> Int`](/documentation/Swift/AnyRandomAccessCollection/distance(from:to:))

Returns the distance between two indices.

[`func formIndex(after: inout AnyRandomAccessCollection<Element>.Index)`](/documentation/Swift/AnyRandomAccessCollection/formIndex(after:))

Replaces the given index with its successor.

[`func formIndex(before: inout AnyRandomAccessCollection<Element>.Index)`](/documentation/Swift/AnyRandomAccessCollection/formIndex(before:))

Replaces the given index with its predecessor.

[`func index(AnyRandomAccessCollection<Element>.Index, offsetBy: Int) -> AnyRandomAccessCollection<Element>.Index`](/documentation/Swift/AnyRandomAccessCollection/index(_:offsetBy:))

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

[`func index(AnyRandomAccessCollection<Element>.Index, offsetBy: Int, limitedBy: AnyRandomAccessCollection<Element>.Index) -> AnyRandomAccessCollection<Element>.Index?`](/documentation/Swift/AnyRandomAccessCollection/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: AnyRandomAccessCollection<Element>.Index) -> AnyRandomAccessCollection<Element>.Index`](/documentation/Swift/AnyRandomAccessCollection/index(after:))

Returns the position immediately after the given index.

[`func index(before: AnyRandomAccessCollection<Element>.Index) -> AnyRandomAccessCollection<Element>.Index`](/documentation/Swift/AnyRandomAccessCollection/index(before:))

Returns the position immediately before the given index.

### Subscripts

[`subscript(AnyRandomAccessCollection<Element>.Index) -> Element`](/documentation/Swift/AnyRandomAccessCollection/subscript(_:)-37hui)

Accesses the element indicated by `position`.

[`subscript(Range<AnyRandomAccessCollection<Element>.Index>) -> AnyRandomAccessCollection<Element>.SubSequence`](/documentation/Swift/AnyRandomAccessCollection/subscript(_:)-6jydx)

Accesses a contiguous subrange of the collection’s elements.

---

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)