<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 8.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/IndexSet/RangeView-swift.struct",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation8IndexSetV9RangeViewV"
  },
  "title" : "IndexSet.RangeView"
}
-->

# IndexSet.RangeView

A view of the contents of an IndexSet, organized by range.

```
struct RangeView
```

## Overview

For example, if an IndexSet is composed of: `[1..<5]` and `[7..<10]` and `[13]` then calling `next()` on this view’s iterator will produce 3 ranges before returning nil.

## Topics

### Counting Indexes

[`count`](/documentation/Foundation/IndexSet/count)

Returns the number of integers in `self`.

[`endIndex`](/documentation/Foundation/IndexSet/RangeView-swift.struct/endIndex)

The ending index in the range.

[`first`](/documentation/Foundation/IndexSet/first)

The first integer in `self`, or nil if `self` is empty.

[`isEmpty`](/documentation/Foundation/IndexSet/isEmpty)

Returns `true` if self contains no values.

[`last`](/documentation/Foundation/IndexSet/last)

The last integer in `self`, or nil if `self` is empty.

[`startIndex`](/documentation/Foundation/IndexSet/RangeView-swift.struct/startIndex)

The beginning index in the range.

### Accessing Indexes

[`subscript(_:)`](/documentation/Foundation/IndexSet/RangeView-swift.struct/subscript(_:)-5r66q)

Accesses the items at the given range of indexes.

[`subscript(_:)`](/documentation/Foundation/IndexSet/RangeView-swift.struct/subscript(_:)-8gh0x)

Accesses the item at the given index.

### Finding Indexes

[`startIndex`](/documentation/Foundation/IndexSet/RangeView-swift.struct/startIndex)

The beginning index in the range.

[`endIndex`](/documentation/Foundation/IndexSet/RangeView-swift.struct/endIndex)

The ending index in the range.

[`index(after:)`](/documentation/Foundation/IndexSet/RangeView-swift.struct/index(after:))

Returns the index in the range after the specified one.

[`index(before:)`](/documentation/Foundation/IndexSet/RangeView-swift.struct/index(before:))

Returns the index in the range before the specified one.

### Selecting Indexes

### Excluding Indexes

### Transforming a Range

### Iterating over Indexes

[`makeIterator()`](/documentation/Foundation/IndexSet/RangeView-swift.struct/makeIterator())

Returns an iterator over the indexes of this range view.

### Sorting Indexes

### Splitting and Joining Ranges

### Testing for Inclusion in the Range

[`contains(_:)`](/documentation/Foundation/IndexSet/contains(_:))

Returns `true` if `self` contains `integer`.

[`index(after:)`](/documentation/Foundation/IndexSet/RangeView-swift.struct/index(after:))

Returns the index in the range after the specified one.

[`index(before:)`](/documentation/Foundation/IndexSet/RangeView-swift.struct/index(before:))

Returns the index in the range before the specified one.

[`makeIterator()`](/documentation/Foundation/IndexSet/RangeView-swift.struct/makeIterator())

Returns an iterator over the indexes of this range view.

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Collection`](/documentation/Swift/Collection)

[`Sendable`](/documentation/Swift/Sendable)

[`Sequence`](/documentation/Swift/Sequence)

[`BidirectionalCollection`](/documentation/Swift/BidirectionalCollection)

---

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)