Instance Methodswift 6.0.1Swift
insert(_:within:)
Inserts a range that contains only the specified index into the range set.
- iOS
- 18.0+
- macOS
- 15.0+
- tvOS
- 18.0+
- visionOS
- 2.0+
- watchOS
- 11.0+
@discardableResult mutating func insert<C>(_ index: Bound, within collection: C) -> Bool where Bound == C.Index, C : Collection
Parameters
- index
The index to insert into the range set.
index
must be a valid index ofcollection
that isn’t the collection’sendIndex
.- collection
The collection that contains
index
.
Returns
true
if the range set was modified, or false
if the given index
was already in the range set.
Other members in extension
Types
struct Ranges
A collection of the ranges that make up a range set.
Type members
init<S, C>(S, within: C
) Creates a new range set containing ranges that contain only the specified indices in the given collection.
static func == (left: RangeSet<Bound>, right: RangeSet<Bound>
) -> Bool
Instance members
var description: String
func formIntersection(RangeSet<Bound>
) Removes the contents of this range set that aren’t also in the given range set.
func formSymmetricDifference(RangeSet<Bound>
) Removes the contents of this range set that are also in the given set and adds the contents of the given set that are not already in this range set.
func formUnion(RangeSet<Bound>
) Adds the contents of the given range set to this range set.
func intersection(RangeSet<Bound>
) -> RangeSet<Bound> Returns a new range set containing the contents of both this set and the given set.
func isDisjoint(RangeSet<Bound>
) -> Bool Returns a Boolean value that indicates whether this range set set has no members in common with the given set.
func isStrictSubset(of: RangeSet<Bound>
) -> Bool Returns a Boolean value that indicates whether this range set is a strict subset of the given set.
func isStrictSuperset(of: RangeSet<Bound>
) -> Bool Returns a Boolean value that indicates whether this range set is a strict superset of the given set.
func isSubset(of: RangeSet<Bound>
) -> Bool Returns a Boolean value that indicates whether this range set is a subset of the given set.
func isSuperset(of: RangeSet<Bound>
) -> Bool Returns a Boolean value that indicates whether this range set is a superset of the given set.
func remove<C>(Bound, within: C
) Removes the range that contains only the specified index from the range set.
func subtract(RangeSet<Bound>
) Removes the contents of the given range set from this range set.
func subtracting(RangeSet<Bound>
) -> RangeSet<Bound> Returns a new set containing the contents of this range set that are not also in the given range set.
func symmetricDifference(RangeSet<Bound>
) -> RangeSet<Bound> Returns a new range set representing the values in this range set or the given range set, but not both.
func union(RangeSet<Bound>
) -> RangeSet<Bound> Returns a new range set containing the contents of both this set and the given set.