for theChar in s.characters {
//something
}
效率:
1.pngfor i in 0..<s.characters.count {
let theChar = s[s.index(s.startIndex, offsetBy: i)]
//something
}
效率:
2.png for theChar in s.characters {
//something
}
效率:
1.pngfor i in 0..<s.characters.count {
let theChar = s[s.index(s.startIndex, offsetBy: i)]
//something
}
效率:
2.png本文标题:[Swift]字符串遍历效率记录
本文链接:https://www.haomeiwen.com/subject/slopittx.html
网友评论