Skip to content

Commit 779ea19

Browse files
committed
Revert count(where:)
1 parent cf53143 commit 779ea19

File tree

7 files changed

+4
-189
lines changed

7 files changed

+4
-189
lines changed

benchmark/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ set(SWIFT_BENCH_MODULES
5858
single-source/ClassArrayGetter
5959
single-source/Codable
6060
single-source/Combos
61-
single-source/CountAlgo
6261
single-source/DataBenchmarks
6362
single-source/DeadArray
6463
single-source/DictOfArraysToArrayOfDicts

benchmark/single-source/CountAlgo.swift

Lines changed: 0 additions & 127 deletions
This file was deleted.

benchmark/utils/main.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import Chars
4646
import ClassArrayGetter
4747
import Codable
4848
import Combos
49-
import CountAlgo
5049
import DataBenchmarks
5150
import DeadArray
5251
import DictOfArraysToArrayOfDicts
@@ -217,7 +216,6 @@ registerBenchmark(CharacterPropertiesPrecomputed)
217216
registerBenchmark(Chars)
218217
registerBenchmark(Codable)
219218
registerBenchmark(Combos)
220-
registerBenchmark(CountAlgo)
221219
registerBenchmark(ClassArrayGetter)
222220
registerBenchmark(DataBenchmarks)
223221
registerBenchmark(DeadArray)

stdlib/public/core/SequenceAlgorithms.swift

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -572,50 +572,6 @@ extension Sequence where Element : Equatable {
572572
}
573573
}
574574

575-
//===----------------------------------------------------------------------===//
576-
// count(where:)
577-
//===----------------------------------------------------------------------===//
578-
579-
extension Sequence {
580-
/// Returns the number of elements in the sequence that satisfy the given
581-
/// predicate.
582-
///
583-
/// You can use this method to count the number of elements that pass a test.
584-
/// The following example finds the number of names that are fewer than
585-
/// five characters long:
586-
///
587-
/// let names = ["Jacqueline", "Ian", "Amy", "Juan", "Soroush", "Tiffany"]
588-
/// let shortNameCount = names.count(where: { $0.count < 5 })
589-
/// // shortNameCount == 3
590-
///
591-
/// To find the number of times a specific element appears in the sequence,
592-
/// use the equal to operator (`==`) in the closure to test for a match.
593-
///
594-
/// let birds = ["duck", "duck", "duck", "duck", "goose"]
595-
/// let duckCount = birds.count(where: { $0 == "duck" })
596-
/// // duckCount == 4
597-
///
598-
/// The sequence must be finite.
599-
///
600-
/// - Parameter predicate: A closure that takes each element of the sequence
601-
/// as its argument and returns a Boolean value indicating whether
602-
/// the element should be included in the count.
603-
/// - Returns: The number of elements in the sequence that satisfy the given
604-
/// predicate.
605-
@inlinable
606-
public func count(
607-
where predicate: (Element) throws -> Bool
608-
) rethrows -> Int {
609-
var count = 0
610-
for e in self {
611-
if try predicate(e) {
612-
count += 1
613-
}
614-
}
615-
return count
616-
}
617-
}
618-
619575
//===----------------------------------------------------------------------===//
620576
// reduce()
621577
//===----------------------------------------------------------------------===//

test/api-digester/Outputs/stability-stdlib-abi.swift.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,5 @@ Subscript String.UnicodeScalarView.subscript(_:) has been removed
8585
Subscript Substring.subscript(_:) has been removed
8686

8787
Func Collection.makeIterator() has self access kind changing from NonMutating to __Consuming
88+
89+
Func Sequence.count(where:) has been removed

test/api-digester/Outputs/stability-stdlib-source.swift.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ Protocol SIMD has added inherited protocol Decodable
44
Protocol SIMD has added inherited protocol Encodable
55
Protocol SIMD has generic signature change from <Self : CustomStringConvertible, Self : ExpressibleByArrayLiteral, Self : Hashable, Self : SIMDStorage, Self.MaskStorage : SIMD, Self.MaskStorage.Scalar : FixedWidthInteger, Self.MaskStorage.Scalar : SignedInteger> to <Self : CustomStringConvertible, Self : Decodable, Self : Encodable, Self : ExpressibleByArrayLiteral, Self : Hashable, Self : SIMDStorage, Self.MaskStorage : SIMD, Self.MaskStorage.Scalar : FixedWidthInteger, Self.MaskStorage.Scalar : SignedInteger>
66
Protocol SIMDStorage has generic signature change from <Self.Scalar : Hashable> to <Self.Scalar : Decodable, Self.Scalar : Encodable, Self.Scalar : Hashable>
7+
8+
Func Sequence.count(where:) has been removed

validation-test/stdlib/SequenceType.swift.gyb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -628,21 +628,6 @@ SequenceTypeTests.test("allSatisfy/Predicate") {
628628
}
629629
}
630630

631-
//===----------------------------------------------------------------------===//
632-
// count(where:)
633-
//===----------------------------------------------------------------------===//
634-
635-
SequenceTypeTests.test("count/Predicate") {
636-
for test in predicateCountTests {
637-
let s = MinimalSequence<OpaqueValue<Int>>(
638-
elements: test.sequence.map { OpaqueValue($0) })
639-
expectEqual(
640-
test.expected,
641-
s.count(where: { test.includeElement($0.value) }),
642-
stackTrace: SourceLocStack().with(test.loc))
643-
}
644-
}
645-
646631
//===----------------------------------------------------------------------===//
647632
// reduce()
648633
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)