Generic Instance Method

# elementsEqual(_:)

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

## Declaration

Available when Element conforms to Equatable.

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

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

Complexity: O(m), where m is the lesser of the length of the sequence and the length of other.

### Comparing Arrays

static func == (Array<Element>, Array<Element>) -> Bool

Returns a Boolean value indicating whether two arrays contain the same elements in the same order.

static func != (Array<Element>, Array<Element>) -> Bool

Returns a Boolean value indicating whether two values are not equal.

func elementsEqual<OtherSequence>(OtherSequence, by: (Element, OtherSequence.Element) -> Bool) -> Bool

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.

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 starts<PossiblePrefix>(with: PossiblePrefix, by: (Element, PossiblePrefix.Element) -> Bool) -> Bool

Returns a Boolean value indicating whether the initial elements of the sequence are equivalent to the elements in another sequence, using the given predicate as the equivalence test.

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: (Element, 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.