swift 泛型中的where 比较两个数组是否相等

//: FROM  https://www.anuomob.com

import UIKit
protocol Container{
    associatedtype Item
    mutating func append(_ item:Item)
    var count:Int{get}
    subscript(i:Int)->Item {get}
    
    associatedtype Iterator:IteratorProtocol where Iterator.Element == Item
    func makeIterator()->Iterator
    
}
protocol ComparableContainer:Container where Item:Comparable {
    
}

func allItemsMatch(container:C1,antherContainer:C2)->Bool where C1.Item==C2.Item,C1.Item:Equatable{
    if container.count != antherContainer.count{
        return false
    }
    for i in 0 ..< container.count{
        if container[i] != antherContainer[i] {
            return false
        }
    }
    return true
    
    
}

 

你可能感兴趣的:(#,swift)