We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 25fa223 commit a9104b3Copy full SHA for a9104b3
2 files changed
Sources/SortedArray.swift
@@ -150,6 +150,18 @@ extension SortedArray {
150
_elements.removeSubrange(bounds)
151
}
152
153
+ // Starting with Swift 4.2, CountableRange and CountableClosedRange are typealiases for
154
+ // Range and ClosedRange, so these methods trigger "Invalid redeclaration" errors.
155
+ // Compile them only for older compiler versions.
156
+ // swift(3.1): Latest version of Swift 3 under the Swift 3 compiler.
157
+ // swift(3.2): Swift 4 compiler under Swift 3 mode.
158
+ // swift(3.3): Swift 4.1 compiler under Swift 3 mode.
159
+ // swift(3.4): Swift 4.2 compiler under Swift 3 mode.
160
+ // swift(4.0): Swift 4 compiler
161
+ // swift(4.1): Swift 4.1 compiler
162
+ // swift(4.1.50): Swift 4.2 compiler in Swift 4 mode
163
+ // swift(4.2): Swift 4.2 compiler
164
+ #if !swift(>=4.1.50)
165
/// Removes the elements in the specified subrange from the array.
166
///
167
/// - Parameter bounds: The range of the array to be removed. The
@@ -169,6 +181,7 @@ extension SortedArray {
169
181
public mutating func removeSubrange(_ bounds: CountableClosedRange<Int>) {
170
182
171
183
184
+ #endif
172
185
173
186
/// Removes the specified number of elements from the beginning of the
174
187
/// array.
Tests/SortedArrayTests/SortedArrayTests.swift
@@ -273,6 +273,13 @@ class SortedArrayTests: XCTestCase {
273
assertElementsEqual(sut, ["a","b"])
274
275
276
+ func testRemoveCountableSubrange() {
277
+ var sut = SortedArray(unsorted: ["a","d","c","b"])
278
+ let countableRange: CountableRange<Int> = 2..<4
279
+ sut.removeSubrange(countableRange)
280
+ assertElementsEqual(sut, ["a","b"])
281
+ }
282
+
283
func testRemoveFirst() {
284
var sut = SortedArray(unsorted: [3,4,2,1])
285
let removedElement = sut.removeFirst()
@@ -379,6 +386,7 @@ extension SortedArrayTests {
379
386
("testFilter", testFilter),
380
387
("testRemoveAtIndex", testRemoveAtIndex),
381
388
("testRemoveSubrange", testRemoveSubrange),
389
+ ("testRemoveCountableSubrange", testRemoveCountableSubrange),
382
390
("testRemoveFirst", testRemoveFirst),
383
391
("testRemoveFirstN", testRemoveFirstN),
384
392
("testRemoveLast", testRemoveLast),
0 commit comments