Returns a Boolean value indicating whether this sequence and another sequence contain equivalent elements in the same order, using the given predicate as the equivalence test.
SDK
- Xcode 9.3+
Framework
- Swift Standard Library
Declaration
Parameters
other
A sequence to compare to this sequence.
areEquivalent
A predicate that returns
true
if its two arguments are equivalent; otherwise,false
.
Return Value
true
if this sequence and other
contain equivalent items, using are
as the equivalence test; otherwise, false.
Discussion
At least one of the sequences must be finite.
The predicate must be a equivalence relation over the elements. That is, for any elements a
, b
, and c
, the following conditions must hold:
Complexity: O(m), where m is the lesser of the length of the sequence and the length of other
.
are
is alwaysEquivalent(a, a) true
. (Reflexivity)are
impliesEquivalent(a, b) are
. (Symmetry)Equivalent(b, a) If
are
andEquivalent(a, b) are
are bothEquivalent(b, c) true
, thenare
is alsoEquivalent(a, c) true
. (Transitivity)