Generic Instance Method

# elementsEqual(_:by:)

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.

## 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 `areEquivalent` 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`.

• `areEquivalent(a, a)` is always `true`. (Reflexivity)

• `areEquivalent(a, b)` implies `areEquivalent(b, a)`. (Symmetry)

• If `areEquivalent(a, b)` and `areEquivalent(b, c)` are both `true`, then `areEquivalent(a, c)` is also `true`. (Transitivity)

### Comparing Sequences

`func elementsEqual<OtherSequence>(OtherSequence) -> Bool`

Returns a Boolean value indicating whether this sequence and another sequence contain the same elements in the same order.

`func starts<PossiblePrefix>(with: PossiblePrefix) -> Bool`

Returns a Boolean value indicating whether the initial elements of the sequence are the same as the elements in another sequence.

`func lexicographicallyPrecedes<OtherSequence>(OtherSequence) -> Bool`

Returns a Boolean value indicating whether the sequence precedes another sequence in a lexicographical (dictionary) ordering, using the less-than operator (`<`) to compare elements.

`func lexicographicallyPrecedes<OtherSequence>(OtherSequence, by: (Self.Element, Self.Element) -> Bool) -> Bool`

Returns a Boolean value indicating whether the sequence precedes another sequence in a lexicographical (dictionary) ordering, using the given predicate to compare elements.