📜  圆形数组 swift 代码示例

📅  最后修改于: 2022-03-11 15:01:01.599000             🧑  作者: Mango

代码示例1
extension Array {
    subscript(circular index: Int) -> Element? {
        guard index >= 0 && !isEmpty else { return nil }
        guard index >= count else { return self[index] }
        return self[index % count]
    }
}