protocol RandomAccessCollection
RangeReplaceableCollection支持修改,添加,删除元素的Collection
protocol RangeReplaceableCollection
Sequence支持按顺序逐个遍历元素的类型
Collection支持多次的,非摧毁式的按顺序遍历元素以及支持通过索引下标访问元素的Sequence
protocol BidirectionalCollection
func index(before i: Self.Index) -> Self.Index
protocol Collection
var startIndex: Self.Index { get }var endIndex: Self.Index { get } subscript(position: Self.Index) -> Self.Element { get }func index(after i: Self.Index) -> Self.Index
protocol Sequence
func makeIterator() -> Self.Iterator
BidirectionalCollection支持多次的,非摧毁式的顺序及逆序遍历元素以及支持通过索引下标访问元素的Collection类型
RandomAccessCollection支持通过索引下标随机访问元素的BidirectionalCollection,且时间复杂度为O(1)