// // ArrayUtil.swift // HCQuanfangtong // // Created by Apple on 2022/8/2. // Copyright © 2022 Jyp. All rights reserved. // import Foundation import CoreAudio extension Array{ /// 是否可以添加 /// - Parameter index: <#index description#> /// - Returns: <#description#> func canInsert(at index: Int) -> (Bool, Int){ var index = index if self.count == 0{ index = 0 } else{ if index > self.count{ index = self.count } if index < 0 { index = 0 } } return (true, index) } /// 是否可以删除 /// - Parameter index: <#index description#> /// - Returns: <#description#> func canDelete(at index: Int) -> (Bool, Int){ if self.count == 0{ return (false, 0) } var index = index if index > self.count - 1{ index = self.count - 1 } if index < 0 { index = 0 } return (true, index) } /// 是否可以查询到 /// - Parameter index: <#index description#> /// - Returns: <#description#> func canGet(at index: Int) -> (Bool, Int){ if self.count == 0{ return (false, 0) } var index = index if index > self.count - 1{ index = self.count - 1 } if index < 0{ index = 0 } return (true, index) } }