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

removeLast(_:)

Removes the specified number of elements from the end of the collection. 指定された数の要素をコレクションの終わりから削除します。

Declaration 宣言

mutating func removeLast(_ k: Int)

Parameters パラメータ

k

The number of elements to remove from the collection. k must be greater than or equal to zero and must not exceed the number of elements in the collection. コレクションから削除される要素の数。kは、ゼロより大きいか等しくなければなりません、そしてコレクションの中の要素の数を越えてはいけません。

Discussion 解説

Attempting to remove more elements than exist in the collection triggers a runtime error. コレクションの中に存在するより多くの要素の削除を試みることは実行時エラーの引き金となります。

Calling this method may invalidate all saved indices of this collection. Do not rely on a previously stored index value after altering a collection with any operation that can change its length. このメソッドを呼び出すことは、このコレクションの全ての保存されたインデックスを無効にします。あるコレクションをそれの長さを変える何らかの演算で手直し後に、以前に格納されたインデックス値を当てにしないでください。

Complexity: O(k), where k is the specified number of elements. 計算量:O(k)、ここでkは指定された要素の数です。

See Also 参照

Removing Elements 要素の削除