One Logo Pool Ball
Foundation · IOS API REFERENCE

IndexSet

struct · iOS 8.0+ · SDK 27.1

struct IndexSet

A collection of unique integer values that represent the indexes of elements in another collection. The range of valid integer values is 0..<INT_MAX-1. Anything outside this range is an error.

Members (56)

get · iOS 8.0+

endIndex

TypeScript
get endIndex(): IndexSet_Index
Swift declaration
var endIndex: IndexSet.Index { get }

The ending index in the set.

method · iOS 8.0+

formIndex

TypeScript
formIndexAfter(i: IndexSet_Index): { $ret: null; $out: { "i": IndexSet_Index } }
Swift declaration
func formIndex(after i: inout IndexSet.Index)

Modifies the given index to refer to the item after the one it currently refers to.

Omit the output parameters from the call. The result contains $ret and $out, with i inside $out.

method · iOS 8.0+

formIndex

TypeScript
formIndexBefore(i: IndexSet_Index): { $ret: null; $out: { "i": IndexSet_Index } }
Swift declaration
func formIndex(before i: inout IndexSet.Index)

Modifies the given index to refer to the item before the one it currently refers to.

Omit the output parameters from the call. The result contains $ret and $out, with i inside $out.

get · iOS 8.0+

startIndex

TypeScript
get startIndex(): IndexSet_Index
Swift declaration
var startIndex: IndexSet.Index { get }

The beginning index in the set.

method · iOS 8.0+

filteredIndexSet

TypeScript
filteredIndexSetIncludeInteger(includeInteger: ((arg0: number) => boolean)): IndexSet
Swift declaration
func filteredIndexSet(includeInteger: (IndexSet.Element) throws -> Bool) rethrows -> IndexSet

Returns an IndexSet filtered according to the result of `includeInteger`. - parameter includeInteger: The predicate which decides if an integer will be included in the result or not.

method · iOS 8.0+

filteredIndexSet

TypeScript
filteredIndexSetInIncludeInteger(range: SDKHandle, includeInteger: ((arg0: number) => boolean)): IndexSet
Swift declaration
func filteredIndexSet(in range: ClosedRange<IndexSet.Element>, includeInteger: (IndexSet.Element) throws -> Bool) rethrows -> IndexSet

Returns an IndexSet filtered according to the result of `includeInteger`. - parameter range: A range of integers. For each integer in the range that intersects the integers in the IndexSet, then the `includeInteger` predicate will be invoked. - parameter includeInteger: The predicate which decides if an integer will be included in the result or not.

method · iOS 8.0+

filteredIndexSet

TypeScript
filteredIndexSetInIncludeInteger84484(range: SDKHandle, includeInteger: ((arg0: number) => boolean)): IndexSet
Swift declaration
func filteredIndexSet(in range: Range<IndexSet.Element>, includeInteger: (IndexSet.Element) throws -> Bool) rethrows -> IndexSet

Returns an IndexSet filtered according to the result of `includeInteger`. - parameter range: A range of integers. For each integer in the range that intersects the integers in the IndexSet, then the `includeInteger` predicate will be invoked. - parameter includeInteger: The predicate which decides if an integer will be included in the result or not.

method · iOS 8.0+

indexRange

TypeScript
indexRangeIn(range: SDKHandle): SDKHandle
Swift declaration
func indexRange(in range: Range<IndexSet.Element>) -> Range<IndexSet.Index>

Return a `Range<IndexSet.Index>` which can be used to subscript the index set. The resulting range is the range of the intersection of the integers in `range` with the index set. The resulting range will be `isEmpty` if the intersection is empty. - parameter range: The range of integers to include.

method · iOS 8.0+

indexRange

TypeScript
indexRangeIn76027(range: SDKHandle): SDKHandle
Swift declaration
func indexRange<R>(in range: R) -> Range<IndexSet.Index> where R : RangeExpression, R.Bound == Int

Return a `Range<IndexSet.Index>` which can be used to subscript the index set. The resulting range is the range of the intersection of the integers in `range` with the index set. - parameter range: The range of integers to include.

init · iOS 18.0+

init

TypeScript
static initIntegersIn(indices: SDKHandle): (IndexSet) | null
Swift declaration
init?(integersIn indices: RangeSet<Int>)
init · iOS 8.0+

init

TypeScript
static initIntegersIn12337(range: SDKHandle): IndexSet
Swift declaration
init(integersIn range: Range<IndexSet.Element>)

Initializes an index set with a range of integers.

init · iOS 8.0+

init

TypeScript
static initIntegersIn1035(range: SDKHandle): IndexSet
Swift declaration
init<R>(integersIn range: R) where R : RangeExpression, R.Bound == Int

Initialize an `IndexSet` with a range of integers.

method · iOS 8.0+

intersects

TypeScript
intersectsIntegersIn(range: SDKHandle): boolean
Swift declaration
func intersects(integersIn range: Range<IndexSet.Element>) -> Bool

Returns `true` if `self` intersects any of the integers in `range`.

method · iOS 8.0+

intersects

TypeScript
intersectsIntegersIn44000(range: SDKHandle): boolean
Swift declaration
func intersects<R>(integersIn range: R) -> Bool where R : RangeExpression, R.Bound == Int

Returns `true` if `self` intersects any of the integers in `range`.

get · iOS 8.0+

description

TypeScript
get description(): string
Swift declaration
var description: String { get }

A textual representation of this instance. Calling this property directly is discouraged. Instead, convert an instance of any type to a string by using the `String(describing:)` initializer. This initializer works with any type, and uses the custom `description` property for types that conform to `CustomStringConvertible`: struct Point: CustomStringConvertible { let x: Int, y: Int var description: String { return "(\(x), \(y))" } } let p = Point(x: 21, y: 30) let s = String(describing: p) print(s) // Prints "(21, 30)" The conversion of `p` to a string in the assignment to `s` uses the `Point` type's `description` property.

get · iOS 8.0+

customMirror

TypeScript
get customMirror(): SDKHandle
Swift declaration
var customMirror: Mirror { get }

The custom mirror for this instance. If this type has value semantics, the mirror should be unaffected by subsequent mutations of the instance.

method · iOS 8.0+

intersection

TypeScript
intersection(other: IndexSet): IndexSet
Swift declaration
func intersection(_ other: IndexSet) -> IndexSet

Intersects the `IndexSet` with `other`.

method · iOS 8.0+

makeIterator

TypeScript
makeIterator(): SDKHandle
Swift declaration
func makeIterator() -> IndexingIterator<IndexSet>

Returns an iterator over the elements of this sequence.

method · iOS 8.0+

integerLessThan

TypeScript
integerLessThan(integer: number): (number) | null
Swift declaration
func integerLessThan(_ integer: IndexSet.Element) -> IndexSet.Element?

Returns an integer contained in `self` which is less than `integer`, or `nil` if a result could not be found.

get · iOS 8.0+

debugDescription

TypeScript
get debugDescription(): string
Swift declaration
var debugDescription: String { get }

A textual representation of this instance, suitable for debugging. Calling this property directly is discouraged. Instead, convert an instance of any type to a string by using the `String(reflecting:)` initializer. This initializer works with any type, and uses the custom `debugDescription` property for types that conform to `CustomDebugStringConvertible`: struct Point: CustomDebugStringConvertible { let x: Int, y: Int var debugDescription: String { return "(\(x), \(y))" } } let p = Point(x: 21, y: 30) let s = String(reflecting: p) print(s) // Prints "(21, 30)" The conversion of `p` to a string in the assignment to `s` uses the `Point` type's `debugDescription` property.

method · iOS 8.0+

formIntersection

TypeScript
formIntersection(other: IndexSet): void
Swift declaration
mutating func formIntersection(_ other: IndexSet)

Intersects the `IndexSet` with `other`.

method · iOS 8.0+

integerGreaterThan

TypeScript
integerGreaterThan(integer: number): (number) | null
Swift declaration
func integerGreaterThan(_ integer: IndexSet.Element) -> IndexSet.Element?

Returns an integer contained in `self` which is greater than `integer`, or `nil` if a result could not be found.

method · iOS 8.0+

symmetricDifference

TypeScript
symmetricDifference(other: IndexSet): IndexSet
Swift declaration
func symmetricDifference(_ other: IndexSet) -> IndexSet

Exclusive or the `IndexSet` with `other`.

method · iOS 8.0+

formSymmetricDifference

TypeScript
formSymmetricDifference(other: IndexSet): void
Swift declaration
mutating func formSymmetricDifference(_ other: IndexSet)

Exclusive or the `IndexSet` with `other`.

method · iOS 8.0+

integerLessThanOrEqualTo

TypeScript
integerLessThanOrEqualTo(integer: number): (number) | null
Swift declaration
func integerLessThanOrEqualTo(_ integer: IndexSet.Element) -> IndexSet.Element?

Returns an integer contained in `self` which is less than or equal to `integer`, or `nil` if a result could not be found.

method · iOS 8.0+

integerGreaterThanOrEqualTo

TypeScript
integerGreaterThanOrEqualTo(integer: number): (number) | null
Swift declaration
func integerGreaterThanOrEqualTo(_ integer: IndexSet.Element) -> IndexSet.Element?

Returns an integer contained in `self` which is greater than or equal to `integer`, or `nil` if a result could not be found.

get · iOS 8.0+

last

TypeScript
get last(): (number) | null
Swift declaration
var last: IndexSet.Element? { get }

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

method · iOS 8.0+

count

TypeScript
countIn(range: SDKHandle): number
Swift declaration
func count(in range: Range<IndexSet.Element>) -> Int

Returns the count of integers in `self` that intersect `range`.

method · iOS 8.0+

count

TypeScript
countIn73912(range: SDKHandle): number
Swift declaration
func count<R>(in range: R) -> Int where R : RangeExpression, R.Bound == Int

Returns the count of integers in `self` that intersect `range`.

get · iOS 8.0+

count

TypeScript
get count(): number
Swift declaration
var count: Int { get }

Returns the number of integers in `self`.

get · iOS 8.0+

first

TypeScript
get first(): (number) | null
Swift declaration
var first: IndexSet.Element? { get }

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

method · iOS 8.0+

index

TypeScript
indexAfter(i: IndexSet_Index): IndexSet_Index
Swift declaration
func index(after i: IndexSet.Index) -> IndexSet.Index

Returns the index that follows the given index in the set.

method · iOS 8.0+

index

TypeScript
indexBefore(i: IndexSet_Index): IndexSet_Index
Swift declaration
func index(before i: IndexSet.Index) -> IndexSet.Index

Returns the index that precedes the given index in the set.

method · iOS 8.0+

shift

TypeScript
shift(integer: number, delta: number): void
Swift declaration
mutating func shift(startingAt integer: IndexSet.Element, by delta: Int)

For a positive delta, shifts the indexes in [index, INT_MAX] to the right, thereby inserting an "empty space" [index, delta], for a negative delta, shifts the indexes in [index, INT_MAX] to the left, thereby deleting the indexes in the range [index - delta, delta].

method · iOS 8.0+

union

TypeScript
union(other: IndexSet): IndexSet
Swift declaration
func union(_ other: IndexSet) -> IndexSet

Union the `IndexSet` with `other`.

method · iOS 8.0+

insert

TypeScript
insertIntegersIn(range: SDKHandle): void
Swift declaration
mutating func insert(integersIn range: Range<IndexSet.Element>)

Insert a range of integers into the `IndexSet`.

method · iOS 8.0+

insert

TypeScript
insertIntegersIn73454(range: SDKHandle): void
Swift declaration
mutating func insert<R>(integersIn range: R) where R : RangeExpression, R.Bound == Int

Insert a range of integers into the `IndexSet`.

method · iOS 8.0+

insert

TypeScript
insert(integer: number): { "inserted": boolean; "memberAfterInsert": number }
Swift declaration
@discardableResult mutating func insert(_ integer: IndexSet.Element) -> (inserted: Bool, memberAfterInsert: IndexSet.Element)

Insert an integer into the `IndexSet`.

method · iOS 8.0+

remove

TypeScript
removeIntegersIn(range: SDKHandle): void
Swift declaration
mutating func remove(integersIn range: ClosedRange<IndexSet.Element>)

Remove a range of integers from the `IndexSet`.

method · iOS 8.0+

remove

TypeScript
removeIntegersIn20292(range: SDKHandle): void
Swift declaration
mutating func remove(integersIn range: Range<IndexSet.Element>)

Remove a range of integers from the `IndexSet`.

method · iOS 8.0+

remove

TypeScript
remove(integer: number): (number) | null
Swift declaration
@discardableResult mutating func remove(_ integer: IndexSet.Element) -> IndexSet.Element?

Remove an integer from the `IndexSet`.

method · iOS 8.0+

update

TypeScript
update(integer: number): (number) | null
Swift declaration
@discardableResult mutating func update(with integer: IndexSet.Element) -> IndexSet.Element?

Insert an integer into the `IndexSet`.

init · iOS 8.0+

init

TypeScript
static initInteger(integer: number): IndexSet
Swift declaration
init(integer: IndexSet.Element)

Initializes an index set with a single integer.

get · iOS 8.0+

isEmpty

TypeScript
get isEmpty(): boolean
Swift declaration
var isEmpty: Bool { get }

Returns `true` if self contains no values.

method · iOS 8.0+

contains

TypeScript
containsIntegersIn(indexSet: IndexSet): boolean
Swift declaration
func contains(integersIn indexSet: IndexSet) -> Bool

Returns `true` if `self` contains all of the integers in `indexSet`.

method · iOS 8.0+

contains

TypeScript
containsIntegersIn32721(range: SDKHandle): boolean
Swift declaration
func contains(integersIn range: Range<IndexSet.Element>) -> Bool

Returns `true` if `self` contains all of the integers in `range`.

method · iOS 8.0+

contains

TypeScript
containsIntegersIn83322(range: SDKHandle): boolean
Swift declaration
func contains<R>(integersIn range: R) -> Bool where R : RangeExpression, R.Bound == Int

Returns `true` if `self` contains all of the integers in `range`.

method · iOS 8.0+

contains

TypeScript
contains(integer: number): boolean
Swift declaration
func contains(_ integer: IndexSet.Element) -> Bool

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

method · iOS 8.0+

formUnion

TypeScript
formUnion(other: IndexSet): void
Swift declaration
mutating func formUnion(_ other: IndexSet)

Union the `IndexSet` with `other`.

method · iOS 8.0+

rangeView

TypeScript
rangeViewOf(range: SDKHandle): IndexSet_RangeView
Swift declaration
func rangeView(of range: Range<IndexSet.Element>) -> IndexSet.RangeView

Returns a `Range`-based view of `self`. - parameter range: A subrange of `self` to view.

method · iOS 8.0+

rangeView

TypeScript
rangeViewOf33558(range: SDKHandle): IndexSet_RangeView
Swift declaration
func rangeView<R>(of range: R) -> IndexSet.RangeView where R : RangeExpression, R.Bound == Int

Returns a `Range`-based view of `self`. - parameter range: A subrange of `self` to view.

get · iOS 8.0+

rangeView

TypeScript
get rangeView(): IndexSet_RangeView
Swift declaration
var rangeView: IndexSet.RangeView { get }

Returns a `Range`-based view of the entire contents of `self`. - seealso: rangeView(of:)

method · iOS 8.0+

removeAll

TypeScript
removeAll(): void
Swift declaration
mutating func removeAll()

Remove all values from the `IndexSet`.

init · iOS 8.0+

init

TypeScript
static init(): IndexSet
Swift declaration
init()

Initializes an empty index set.

subscript · iOS 8.0+

subscript

TypeScript
subscript(index: IndexSet_Index): number
Swift declaration
subscript(index: IndexSet.Index) -> IndexSet.Element { get }

Accesses one element in the index set.

subscript · iOS 8.0+

subscript

TypeScript
subscript4044(bounds: SDKHandle): SDKHandle
Swift declaration
subscript(bounds: Range<IndexSet.Index>) -> Slice<IndexSet> { get }

Accesses a contiguous subrange of the collection's elements. The accessed slice uses the same indices for the same elements as the original collection uses. Always use the slice's `startIndex` property instead of assuming that its indices start at a particular value. This example demonstrates getting a slice of an array of strings, finding the index of one of the strings in the slice, and then using that index in the original array. let streets = ["Adams", "Bryant", "Channing", "Douglas", "Evarts"] let streetsSlice = streets[2 ..< streets.endIndex] print(streetsSlice) // Prints "["Channing", "Douglas", "Evarts"]" let index = streetsSlice.firstIndex(of: "Evarts") // 4 print(streets[index!]) // Prints "Evarts" - Parameter bounds: A range of the collection's indices. The bounds of the range must be valid indices of the collection. - Complexity: O(1)

Skipped declarations

No declarations were skipped in this snapshot.

All Foundation types →