Searching in sorted arrays

is there Array's (or perhaps Collection's?) equivalent of Foundation's:

NSArray method:
func index(of obj: Any, inSortedRange r: NSRange, options opts: NSBinarySearchingOptions = [], usingComparator cmp: (Any, Any) -> ComparisonResult) -> Int

Not in the stdlib publicly AFAICT, but swift-algorithms provides a binary search to sorted random access collections by the name of partitioningIndex(where:). swift-algorithms/Partition.md at main · apple/swift-algorithms · GitHub

2 Likes
Terms of Service

Privacy Policy

Cookie Policy