Index
The mechanism for accessing the integers stored in an IndexSet.
struct Index
The mechanism for accessing the integers stored in an IndexSet.
struct Index
import Foundation
struct IndexSet
Manages a Set
of integer values, which are commonly used as an index type in Cocoa API.
init()
Initialize an empty IndexSet
.
init(from decoder: any Decoder) throws
init(integer: IndexSet.Element)
Initialize an IndexSet
with a single integer.
init(integersIn range: Range<IndexSet.Element>)
Initialize an IndexSet
with a range of integers.
init<R>(integersIn range: R) where R : RangeExpression, R.Bound == Int
Initialize an IndexSet
with a range of integers.
var count: Int { get }
Returns the number of integers in self
.
var customMirror: Mirror { get }
var debugDescription: String { get }
var description: String { get }
var endIndex: IndexSet.Index { get }
var first: IndexSet.Element? { get }
Returns the first integer in self
, or nil if self
is empty.
var isEmpty: Bool { get }
Returns true
if self contains no values.
var last: IndexSet.Element? { get }
Returns the last integer in self
, or nil if self
is empty.
var rangeView: IndexSet.RangeView { get }
Returns a Range
-based view of the entire contents of self
.
var startIndex: IndexSet.Index { get }
subscript(index: IndexSet.Index) -> IndexSet.Element { get }
subscript(bounds: Range<IndexSet.Index>) -> Slice<IndexSet> { get }
static func == (lhs: IndexSet, rhs: IndexSet) -> Bool
func contains(_ integer: IndexSet.Element) -> Bool
Returns true
if self
contains integer
.
func contains(integersIn indexSet: IndexSet) -> Bool
Returns true
if self
contains all of the integers in indexSet
.
func contains(integersIn range: Range<IndexSet.Element>) -> Bool
Returns true
if self
contains all of the integers in range
.
func contains<R>(integersIn range: R) -> Bool where R : RangeExpression, R.Bound == Int
Returns true
if self
contains all of the integers in range
.
func count(in range: Range<IndexSet.Element>) -> Int
Returns the count of integers in self
that intersect range
.
func count<R>(in range: R) -> Int where R : RangeExpression, R.Bound == Int
Returns the count of integers in self
that intersect range
.
func encode(to encoder: any Encoder) throws
func filteredIndexSet(in range: ClosedRange<IndexSet.Element>, includeInteger: (IndexSet.Element) throws -> Bool) rethrows -> IndexSet
Returns an IndexSet filtered according to the result of includeInteger
.
func filteredIndexSet(in range: Range<IndexSet.Element>, includeInteger: (IndexSet.Element) throws -> Bool) rethrows -> IndexSet
Returns an IndexSet filtered according to the result of includeInteger
.
func filteredIndexSet(includeInteger: (IndexSet.Element) throws -> Bool) rethrows -> IndexSet
Returns an IndexSet filtered according to the result of includeInteger
.
func formIndex(after i: inout IndexSet.Index)
func formIndex(before i: inout IndexSet.Index)
mutating func formIntersection(_ other: IndexSet)
Intersect the IndexSet
with other
.
mutating func formSymmetricDifference(_ other: IndexSet)
Exclusive or the IndexSet
with other
.
mutating func formUnion(_ other: IndexSet)
Union the IndexSet
with other
.
func hash(into hasher: inout Hasher)
func index(after i: IndexSet.Index) -> IndexSet.Index
func index(before i: IndexSet.Index) -> IndexSet.Index
func indexRange(in range: Range<IndexSet.Element>) -> Range<IndexSet.Index>
Return a Range<IndexSet.Index>
which can be used to subscript the index set.
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.
@discardableResult mutating func insert(_ integer: IndexSet.Element) -> (inserted: Bool, memberAfterInsert: IndexSet.Element)
Insert an integer into the IndexSet
.
mutating func insert(integersIn range: Range<IndexSet.Element>)
Insert a range of integers into the IndexSet
.
mutating func insert<R>(integersIn range: R) where R : RangeExpression, R.Bound == Int
Insert a range of integers into the IndexSet
.
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.
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.
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.
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.
func intersection(_ other: IndexSet) -> IndexSet
Intersect the IndexSet
with other
.
func intersects(integersIn range: Range<IndexSet.Element>) -> Bool
Returns true
if self
intersects any of the integers in range
.
func intersects<R>(integersIn range: R) -> Bool where R : RangeExpression, R.Bound == Int
Returns true
if self
intersects any of the integers in range
.
func makeIterator() -> IndexingIterator<IndexSet>
func rangeView(of range: Range<IndexSet.Element>) -> IndexSet.RangeView
Returns a Range
-based view of self
.
func rangeView<R>(of range: R) -> IndexSet.RangeView where R : RangeExpression, R.Bound == Int
Returns a Range
-based view of self
.
@discardableResult mutating func remove(_ integer: IndexSet.Element) -> IndexSet.Element?
Remove an integer from the IndexSet
.
mutating func remove(integersIn range: ClosedRange<IndexSet.Element>)
Remove a range of integers from the IndexSet
.
mutating func remove(integersIn range: Range<IndexSet.Element>)
Remove a range of integers from the IndexSet
.
mutating func removeAll()
Remove all values from the IndexSet
.
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].
func symmetricDifference(_ other: IndexSet) -> IndexSet
Exclusive or the IndexSet
with other
.
func union(_ other: IndexSet) -> IndexSet
Union the IndexSet
with other
.
@discardableResult mutating func update(with integer: IndexSet.Element) -> IndexSet.Element?
Insert an integer into the IndexSet
.
struct RangeView
An view of the contents of an IndexSet, organized by range.
typealias Element = Int
typealias ReferenceType = NSIndexSet
protocol Comparable : Equatable
A type that can be compared using the relational operators <
, <=
, >=
, and >
.
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Sendable
var description: String { get }
static func < (lhs: IndexSet.Index, rhs: IndexSet.Index) -> Bool
static func <= (lhs: IndexSet.Index, rhs: IndexSet.Index) -> Bool
static func == (lhs: IndexSet.Index, rhs: IndexSet.Index) -> Bool
static func > (lhs: IndexSet.Index, rhs: IndexSet.Index) -> Bool
static func >= (lhs: IndexSet.Index, rhs: IndexSet.Index) -> Bool
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.
static func ... (minimum: Self) -> PartialRangeFrom<Self>
Returns a partial range extending upward from a lower bound.
static func ... (maximum: Self) -> PartialRangeThrough<Self>
Returns a partial range up to, and including, its upper bound.
static func ... (minimum: Self, maximum: Self) -> ClosedRange<Self>
Returns a closed range that contains both of its bounds.
static func ..< (maximum: Self) -> PartialRangeUpTo<Self>
Returns a partial range up to, but not including, its upper bound.
static func ..< (minimum: Self, maximum: Self) -> Range<Self>
Returns a half-open range that contains its lower bound but not its upper bound.
static func <= (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.
static func > (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.
static func >= (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.