Instance Method インスタンスメソッド

formIndex(_:offsetBy:)

Offsets the given index by the specified distance. 与えられたインデックスを指定された間隔で補います。

Declaration 宣言

func formIndex(_ i: inout Int, offsetBy distance: Int)

Parameters パラメータ

i

A valid index of the collection. そのコレクションの有効なインデックス。

distance

The distance to offset i. distance must not be negative unless the collection conforms to the BidirectionalCollection protocol. iを補う間隔。distanceは、そのコレクションがBidirectionalCollectionプロトコルに準拠するのでない限り、負であってはなりません。

Discussion 解説

The value passed as distance must not offset i beyond the bounds of the collection. distanceとして渡される値は、このコレクションの境界を越えてiを補ってはなりません。

Complexity: O(1) if the collection conforms to RandomAccessCollection; otherwise, O(k), where k is the absolute value of distance. 計算量:もしコレクションがRandomAccessCollectionに準拠するならば、O(1);そうでなければ、O(k)、そこでkdistanceの値の絶対値です。

See Also 参照

Manipulating Indices インデックスを操る