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

lexicographicallyPrecedes(_:by:)

Returns a Boolean value indicating whether the sequence precedes another sequence in a lexicographical (dictionary) ordering, using the given predicate to compare elements. シーケンスが別のシーケンスの前に来るかどうかをある語彙筆記的順序(字典)順序において、与えられた述部を使って要素を比較して、指し示すブール値を返します。

Declaration 宣言

func lexicographicallyPrecedes<OtherSequence>(_ other: OtherSequence, by areInIncreasingOrder: (Element, Element) throws -> Bool) rethrows -> Bool where OtherSequence : Sequence, Element == OtherSequence.Element

Parameters パラメータ

other

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

areInIncreasingOrder

A predicate that returns true if its first argument should be ordered before its second argument; otherwise, false. ある述部、それはそれの最初の引数がそれの2番目の引数の前に並べられるべきならばtrueを返します;そうでなければ、false

Return Value 戻り値

true if this sequence precedes other in a dictionary ordering as ordered by areInIncreasingOrder; otherwise, false. true、もしこのシーケンスがotherに、areInIncreasingOrderによって並べられる通りの字典順序において先行するならば;そうでなければ、false

Discussion 解説

The predicate must be a strict weak ordering over the elements. That is, for any elements a, b, and c, the following conditions must hold: 述部は、それら要素に対して厳密弱順序でなければなりません。すなわち、何らかの要素ab、そしてcに対して、以下の条件が保持されなければなりません:

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

  • areInIncreasingOrder(a, a) is always false. (Irreflexivity) areInIncreasingOrder(a, a)は常にfalseである。(非反射)

  • If areInIncreasingOrder(a, b) and areInIncreasingOrder(b, c) are both true, then areInIncreasingOrder(a, c) is also true. (Transitive comparability) areInIncreasingOrder(a, b)areInIncreasingOrder(b, c)が両方ともtrueならば、そのときareInIncreasingOrder(a, c)もまたtrueである。(推移的比較性)

  • Two elements are incomparable if neither is ordered before the other according to the predicate. If a and b are incomparable, and b and c are incomparable, then a and c are also incomparable. (Transitive incomparability) 2つの要素は、述部によるとどちらもが他の前に並べられるならば比較できないabが比較できないならば、そしてbcが比較できないならば、そのときacもまた比較できない。(推移的比較不能性)

See Also 参照

Comparing Arrays 配列の比較