<!--
{
  "documentType" : "article",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/LazySequence/BidirectionalCollection-Implementations",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "BidirectionalCollection Implementations"
}
-->

# BidirectionalCollection Implementations

## Topics

### Instance Properties

[`var last: Self.Element?`](/documentation/Swift/LazySequence/last)

The last element of the collection.

### Instance Methods

[`func difference<C>(from: C) -> CollectionDifference<Self.Element>`](/documentation/Swift/LazySequence/difference(from:))

Returns the difference needed to produce this collection’s ordered
elements from the given collection.

[`func difference<C>(from: C, by: (C.Element, Self.Element) -> Bool) -> CollectionDifference<Self.Element>`](/documentation/Swift/LazySequence/difference(from:by:))

Returns the difference needed to produce this collection’s ordered
elements from the given collection, using the given predicate as an
equivalence test.

[`func distance(from: Self.Index, to: Self.Index) -> Int`](/documentation/Swift/LazySequence/distance(from:to:)-5ong5)

[`func formIndex(before: inout Self.Index)`](/documentation/Swift/LazySequence/formIndex(before:))

Replaces the given index with its predecessor.

[`func index(Self.Index, offsetBy: Int) -> Self.Index`](/documentation/Swift/LazySequence/index(_:offsetBy:)-9c2fj)

[`func index(Self.Index, offsetBy: Int, limitedBy: Self.Index) -> Self.Index?`](/documentation/Swift/LazySequence/index(_:offsetBy:limitedBy:)-9juzm)

[`func index(before: LazySequence<Base>.Index) -> LazySequence<Base>.Index`](/documentation/Swift/LazySequence/index(before:))

Returns the position immediately before the given index.

[`func joined(separator: String) -> String`](/documentation/Swift/LazySequence/joined(separator:)-5e92i)

Returns a new string by concatenating the elements of the sequence,
adding the given separator between each element.

[`func last(where: (Self.Element) throws -> Bool) rethrows -> Self.Element?`](/documentation/Swift/LazySequence/last(where:))

Returns the last element of the sequence that satisfies the given
predicate.

[`func lastIndex(of: Self.Element) -> Self.Index?`](/documentation/Swift/LazySequence/lastIndex(of:))

Returns the last index where the specified value appears in the
collection.

[`func lastIndex(where: (Self.Element) throws -> Bool) rethrows -> Self.Index?`](/documentation/Swift/LazySequence/lastIndex(where:))

Returns the index of the last element in the collection that matches the
given predicate.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)