小编Nav*_*avi的帖子

可街协议

我正在尝试转换以下Swift 2.3代码:

//Example usage:
//(0 ..< 778).binarySearch { $0 < 145 } // 145
extension CollectionType where Index: RandomAccessIndexType {

    /// Finds such index N that predicate is true for all elements up to
    /// but not including the index N, and is false for all elements
    /// starting with index N.
    /// Behavior is undefined if there is no such N.
    func binarySearch(predicate: Generator.Element -> Bool)
        -> Index {
        var low = startIndex
        var high = endIndex
        while low …
Run Code Online (Sandbox Code Playgroud)

swift

2
推荐指数
1
解决办法
602
查看次数

标签 统计

swift ×1