associatedtype Indices
associatedtype SubSequence
Availability
Technology
protocol RandomAccessCollection where Self.Indices
: RandomAccessCollection
, Self.SubSequence
: RandomAccessCollection
Random-access collections can move indices any distance and measure the distance between indices in O(1) time. Therefore, the fundamental difference between random-access and bidirectional collections is that operations that depend on index movement or distance measurement offer significantly improved efficiency. For example, a random-access collection’s count
property is calculated in O(1) instead of requiring iteration of an entire collection.
無作為アクセスのコレクションは、任意の隔たりのインデックスを移動できます、そしてインデックス間の隔たりの測定をO(1)時間で行えます。それゆえに、無作為アクセスと二方向性のコレクションの根本的な違いは、インデックス移動や間隔測定に依存する演算が、著しく改善される効率を提示することです。例えば、無作為アクセスコレクションのもつcount
プロパティは、コレクション全体の反復を要求したりせずにO(1)で計算されます。
The Random
protocol adds further constraints on the associated Indices
and Sub
types, but otherwise imposes no additional requirements over the Bidirectional
protocol. However, in order to meet the complexity guarantees of a random-access collection, either the index for your custom type must conform to the Strideable
protocol or you must implement the index(_:
and distance(from:
methods with O(1) efficiency.
Random
プロトコルは、一層の制約を関連Indices
およびSub
型に加えます、しかしそれ以外ではBidirectional
プロトコルを越える追加要件は課されません。しかしながら、無作為アクセスコレクションの計算量(複雑さ)保証を達成する手段として、あなたのあつらえの型に対するインデックスがStrideable
プロトコルに準拠する、またはあなたがindex(_:
とdistance(from:
メソッドをO(1)の効率で実装する、いずれかをしなければなりません。
associatedtype Indices
associatedtype SubSequence
var indices: Self.Indices
func distance(from: Self.Index, to: Self.Index) -> Int
func formIndex (after: inout Self.Index)
func formIndex (before: inout Self.Index)
func index(Self.Index, offsetBy : Int) -> Self.Index
func index(Self.Index, offsetBy : Int, limitedBy : Self.Index) -> Self.Index?
func index(after: Self.Index) -> Self.Index
func index(before: Self.Index) -> Self.Index
subscript(Range<Self.Index>) -> Self.SubSequence
AnyColumn
AnyColumnSlice
AnyRandomAccessCollection
ArchiveHeader
ArchiveHeader.EntryXATBlob
ArchiveHeader.FieldKeySet
Array
ArraySlice
CMFormatDescription.ParameterSetCollection
CollectionOfOne
Column
ColumnSlice
ContiguousArray
Data
DataFrame.Row
DispatchData
EmptyCollection
ApplicationMusicPlayer.Queue.Entries
FetchedResults
IndexPath
Int.Words
Int16.Words
Int32.Words
Int64.Words
Int8.Words
KeyValuePairs
MIDIEventPacket.WordCollection
MIDIPacket.ByteCollection
MLDataTable.ColumnNames
MLDataTable.Row.Values
MLDataTable.Rows
MLDataValue.SequenceType
ManagedAudioChannelLayout.ChannelDescriptions
MusicItemCollection
PKStrokePath
Repeated
RowGrouping
SectionedFetchResults
SectionedFetchResults.Section
UInt.Words
UInt16.Words
UInt32.Words
UInt64.Words
UInt8.Words
Unicode.Scalar.UTF16View
Unicode.Scalar.UTF8View
UnsafeBufferPointer
UnsafeMutableAudioBufferListPointer
UnsafeMutableBufferPointer
UnsafeMutableMIDIEventPacketPointer
UnsafeMutableMIDIPacketPointer
protocol BidirectionalCollection