You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Swift 3 refactoring of the range type has led to its split into 4
different types. The IndexSet API should accept any of these as long as
they contain the element type (Int, which is inherently Countable). This
allows callers to use both the ... and ..< syntax, for example.
This commit also adds additional unit tests for some of the IndexSet
API, and turns a few methods with optional/default args into properties
or a method family, since otherwise callers would end up with an
ambigious method call as the range argument would have been defaulted to
nil.
<rdar://problem/26532614> Add overloads for range types to IndexSet
/// Returns an IndexSet filtered according to the result of `includeInteger`.
625
709
///
626
-
/// - 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. Pass `nil` (the default) to use the entire range.
710
+
/// - 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.
627
711
/// - parameter includeInteger: The predicate which decides if an integer will be included in the result or not.
628
-
publicfunc filteredIndexSet(in range :Range<Element>?=nil, includeInteger:@noescape(Element)throws->Bool)rethrows->IndexSet{
/// Returns an IndexSet filtered according to the result of `includeInteger`.
735
+
///
736
+
/// - 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.
737
+
/// - parameter includeInteger: The predicate which decides if an integer will be included in the result or not.
738
+
publicfunc filteredIndexSet(in range :CountableRange<Element>, includeInteger:@noescape(Element)throws->Bool)rethrows->IndexSet{returntryself.filteredIndexSet(in:Range(range), includeInteger: includeInteger)}
739
+
/// Returns an IndexSet filtered according to the result of `includeInteger`.
740
+
///
741
+
/// - 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.
742
+
/// - parameter includeInteger: The predicate which decides if an integer will be included in the result or not.
743
+
publicfunc filteredIndexSet(in range :ClosedRange<Element>, includeInteger:@noescape(Element)throws->Bool)rethrows->IndexSet{returntryself.filteredIndexSet(in:Range(range), includeInteger: includeInteger)}
744
+
/// Returns an IndexSet filtered according to the result of `includeInteger`.
745
+
///
746
+
/// - 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.
747
+
/// - parameter includeInteger: The predicate which decides if an integer will be included in the result or not.
748
+
publicfunc filteredIndexSet(in range :CountableClosedRange<Element>, includeInteger:@noescape(Element)throws->Bool)rethrows->IndexSet{returntryself.filteredIndexSet(in:Range(range), includeInteger: includeInteger)}
749
+
750
+
/// Returns an IndexSet filtered according to the result of `includeInteger`.
751
+
///
752
+
/// - parameter includeInteger: The predicate which decides if an integer will be included in the result or not.
/// 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].
651
758
publicmutatingfunc shift(startingAt integer:Element, by delta:IndexSet.IndexDistance){
0 commit comments