@@ -56,7 +56,7 @@ internal func __NSIndexSetIndexOfRangeContainingIndex(_ indexSet: NSIndexSet, _
56
56
return UInt ( bitPattern: NSNotFound)
57
57
}
58
58
59
- open class NSIndexSet : NSObject , NSCopying , NSMutableCopying , NSSecureCoding {
59
+ open class NSIndexSet : NSObject , NSCopying , NSMutableCopying , NSSecureCoding {
60
60
// all instance variables are private
61
61
62
62
internal var _ranges = [ NSRange] ( )
@@ -86,7 +86,7 @@ open class NSIndexSet: NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
86
86
87
87
open func mutableCopy( with zone: NSZone ? = nil ) -> Any {
88
88
let set = NSMutableIndexSet ( )
89
- enumerateRanges ( [ ] ) {
89
+ enumerateRanges ( options : [ ] ) {
90
90
set. add ( in: $0. 0 )
91
91
}
92
92
return set
@@ -340,7 +340,7 @@ open class NSIndexSet: NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
340
340
}
341
341
open func contains( _ indexSet: IndexSet ) -> Bool {
342
342
var result = true
343
- enumerateRanges ( [ ] ) { range, stop in
343
+ enumerateRanges ( options : [ ] ) { range, stop in
344
344
if !self . contains ( in: range) {
345
345
result = false
346
346
stop. pointee = true
@@ -415,20 +415,20 @@ open class NSIndexSet: NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
415
415
return result
416
416
}
417
417
418
- public func enumerate( _ block: ( Int , UnsafeMutablePointer < ObjCBool > ) -> Void ) {
419
- enumerate ( [ ] , using: block)
418
+ open func enumerate( _ block: ( Int , UnsafeMutablePointer < ObjCBool > ) -> Void ) {
419
+ enumerate ( options : [ ] , using: block)
420
420
}
421
- public func enumerate( _ opts: NSEnumerationOptions = [ ] , using block: ( Int , UnsafeMutablePointer < ObjCBool > ) -> Void ) {
421
+ open func enumerate( options opts: NSEnumerationOptions = [ ] , using block: ( Int , UnsafeMutablePointer < ObjCBool > ) -> Void ) {
422
422
let _ = _enumerateWithOptions ( opts, range: NSMakeRange ( 0 , Int . max) , paramType: Int . self, returnType: Void . self, block: block)
423
423
}
424
- public func enumerate( in range: NSRange , options opts: NSEnumerationOptions = [ ] , using block: ( Int , UnsafeMutablePointer < ObjCBool > ) -> Void ) {
424
+ open func enumerate( in range: NSRange , options opts: NSEnumerationOptions = [ ] , using block: ( Int , UnsafeMutablePointer < ObjCBool > ) -> Void ) {
425
425
let _ = _enumerateWithOptions ( opts, range: range, paramType: Int . self, returnType: Void . self, block: block)
426
426
}
427
427
428
428
open func index( passingTest predicate: ( Int , UnsafeMutablePointer < ObjCBool > ) -> Bool ) -> Int {
429
- return index ( [ ] , passingTest: predicate)
429
+ return index ( options : [ ] , passingTest: predicate)
430
430
}
431
- open func index( _ opts: NSEnumerationOptions = [ ] , passingTest predicate: ( Int , UnsafeMutablePointer < ObjCBool > ) -> Bool ) -> Int {
431
+ open func index( options opts: NSEnumerationOptions = [ ] , passingTest predicate: ( Int , UnsafeMutablePointer < ObjCBool > ) -> Bool ) -> Int {
432
432
return _enumerateWithOptions ( opts, range: NSMakeRange ( 0 , Int . max) , paramType: Int . self, returnType: Bool . self, block: predicate) ?? NSNotFound
433
433
}
434
434
open func index( in range: NSRange , options opts: NSEnumerationOptions = [ ] , passingTest predicate: ( Int , UnsafeMutablePointer < ObjCBool > ) -> Bool ) -> Int {
@@ -438,7 +438,7 @@ open class NSIndexSet: NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
438
438
open func indexes( passingTest predicate: ( Int , UnsafeMutablePointer < ObjCBool > ) -> Bool ) -> IndexSet {
439
439
return indexes ( in: NSMakeRange ( 0 , Int . max) , options: [ ] , passingTest: predicate)
440
440
}
441
- open func indexes( _ opts: NSEnumerationOptions = [ ] , passingTest predicate: ( Int , UnsafeMutablePointer < ObjCBool > ) -> Bool ) -> IndexSet {
441
+ open func indexes( options opts: NSEnumerationOptions = [ ] , passingTest predicate: ( Int , UnsafeMutablePointer < ObjCBool > ) -> Bool ) -> IndexSet {
442
442
return indexes ( in: NSMakeRange ( 0 , Int . max) , options: opts, passingTest: predicate)
443
443
}
444
444
open func indexes( in range: NSRange , options opts: NSEnumerationOptions = [ ] , passingTest predicate: ( Int , UnsafeMutablePointer < ObjCBool > ) -> Bool ) -> IndexSet {
@@ -456,47 +456,46 @@ open class NSIndexSet: NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
456
456
457
457
If the specified range for enumeration intersects a range of contiguous indexes in the receiver, then the block will be invoked with the intersection of those two ranges.
458
458
*/
459
- public func enumerateRanges( _ block: ( NSRange , UnsafeMutablePointer < ObjCBool > ) -> Void ) {
460
- enumerateRanges ( [ ] , using: block)
459
+ open func enumerateRanges( _ block: ( NSRange , UnsafeMutablePointer < ObjCBool > ) -> Void ) {
460
+ enumerateRanges ( options : [ ] , using: block)
461
461
}
462
- public func enumerateRanges( _ opts: NSEnumerationOptions = [ ] , using block: ( NSRange , UnsafeMutablePointer < ObjCBool > ) -> Void ) {
462
+ open func enumerateRanges( options opts: NSEnumerationOptions = [ ] , using block: ( NSRange , UnsafeMutablePointer < ObjCBool > ) -> Void ) {
463
463
let _ = _enumerateWithOptions ( opts, range: NSMakeRange ( 0 , Int . max) , paramType: NSRange . self, returnType: Void . self, block: block)
464
464
}
465
- public func enumerateRanges( in range: NSRange , options opts: NSEnumerationOptions = [ ] , using block: ( NSRange , UnsafeMutablePointer < ObjCBool > ) -> Void ) {
465
+ open func enumerateRanges( in range: NSRange , options opts: NSEnumerationOptions = [ ] , using block: ( NSRange , UnsafeMutablePointer < ObjCBool > ) -> Void ) {
466
466
let _ = _enumerateWithOptions ( opts, range: range, paramType: NSRange . self, returnType: Void . self, block: block)
467
467
}
468
468
}
469
469
470
- extension NSIndexSet : Sequence {
471
-
472
- public struct Iterator : IteratorProtocol {
473
- internal let _set : NSIndexSet
474
- internal var _first : Bool = true
475
- internal var _current : Int ?
476
-
477
- internal init ( _ set: NSIndexSet ) {
478
- self . _set = set
479
- self . _current = nil
480
- }
481
-
482
- public mutating func next( ) -> Int ? {
483
- if _first {
484
- _current = _set. firstIndex
485
- _first = false
486
- } else if let c = _current {
487
- _current = _set. indexGreaterThanIndex ( c)
488
- }
489
- if _current == NSNotFound {
490
- _current = nil
491
- }
492
- return _current
493
- }
470
+ public struct NSIndexSetIterator : IteratorProtocol {
471
+ public typealias Element = Int
472
+ internal let _set : NSIndexSet
473
+ internal var _first : Bool = true
474
+ internal var _current : Element ?
475
+
476
+ internal init ( _ set: NSIndexSet ) {
477
+ self . _set = set
478
+ self . _current = nil
494
479
}
495
480
496
- public func makeIterator( ) -> Iterator {
497
- return Iterator ( self )
481
+ public mutating func next( ) -> Element ? {
482
+ if _first {
483
+ _current = _set. firstIndex
484
+ _first = false
485
+ } else if let c = _current {
486
+ _current = _set. indexGreaterThanIndex ( c)
487
+ }
488
+ if _current == NSNotFound {
489
+ _current = nil
490
+ }
491
+ return _current
498
492
}
493
+ }
499
494
495
+ extension NSIndexSet : Sequence {
496
+ public func makeIterator( ) -> NSIndexSetIterator {
497
+ return NSIndexSetIterator ( self )
498
+ }
500
499
}
501
500
502
501
open class NSMutableIndexSet : NSIndexSet {
0 commit comments