Generic Instance Method 総称体インスタンスメソッド

elementsEqual(_:)

Returns a Boolean value indicating whether this sequence and another sequence contain the same elements in the same order. このシーケンスともう一方のシーケンスが同じ要素を同じ順序で含むかどうかを指し示すブール値を返します。

Declaration 宣言

func elementsEqual<OtherSequence>(_ other: OtherSequence) -> Bool where OtherSequence : Sequence, UInt8 == OtherSequence.Element

Parameters パラメータ

other

A sequence to compare to this sequence. あるシーケンス、このシーケンスと比べることになります。

Return Value 戻り値

true if this sequence and other contain the same elements in the same order. このシーケンスとotherが同じ要素を同じ順序で含んでいるならば、true

Discussion 議論

At least one of the sequences must be finite. 少なくともシーケンスのうちの一方は有限でなければなりません。

This example tests whether one countable range shares the same elements as another countable range and an array. この例は、ある可付番範囲が同じ要素を別の可付番範囲とそしてある配列と共有するかどうかをテストします。


let a = 1...3
let b = 1...10


print(a.elementsEqual(b))
// Prints "false"
print(a.elementsEqual([1, 2, 3]))
// Prints "true"

Complexity: O(m), where m is the lesser of the length of the sequence and the length of other. 計算量:O(m)、ここでmはシーケンスの長さおよびotherの長さより少ないものです。

See Also 参照

Comparing Data データを比較する