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

prefix(while:)

Returns a subsequence containing the initial elements until predicate returns false and skipping the remaining elements. predicatefalseを返すまで冒頭の要素を含んでいて残りの要素を飛ばしている、ある下位シーケンスを返します。

Declaration 宣言

func prefix(while predicate: (Base.Element) throws -> Bool) rethrows -> Slice<ReversedCollection<Base>>

Parameters パラメータ

predicate

A closure that takes an element of the sequence as its argument and returns true if the element should be included or false if it should be excluded. Once the predicate returns false it will not be called again. あるクロージャ、それはシーケンスの1つの要素をそれの引数として取り、その要素が含まれるべきならばtrueをまたはそれが除外されるべきならばfalseを返します。いったん述部がfalseを返すならそれは再び呼び出されません。

Discussion 解説

Complexity: O(n), where n is the length of the collection. 計算量:O(n)、ここでnはコレクションの長さです。