BidirectionalCollection
protocol BidirectionalCollection : Collection where Self.Indices : BidirectionalCollection, Self.SubSequence : BidirectionalCollection
-
Obtains the first element of this bidirectional collection or
Option.none
.Declaration
Swift
public var firstOrNone: Option<Element> { get }
-
Obtains the first element of this bidirectional collection that matches a predicate.
Declaration
Swift
public func firstOrNone(_ predicate: (Element) -> Bool) -> Option<Element>
Parameters
predicate
Filtering predicate.
Return Value
First element that matches the predicate or
Option.none
. -
Obtains the last element of this bidirectional collection or
Option.none
.Declaration
Swift
public var lastOrNone: Option<Element> { get }
-
Obtains the last element of this bidirectional collection that matches a predicate.
Declaration
Swift
public func lastOrNone(_ predicate: (Element) -> Bool) -> Option<Element>
Parameters
predicate
Filtering predicate.
Return Value
Last element that matches the predicate or
Option.none
. -
Returns an element if it is the single one in this collection or
Option.none
Declaration
Swift
public var singleOrNone: Option<Element> { get }
-
Returns an element if it is the single one matching a predicate.
Declaration
Swift
public func singleOrNone(_ predicate: (Element) -> Bool) -> Option<Element>
Parameters
predicate
Filtering predicate.
Return Value
A value if it is the single one matching the predicate, or
Option.none
.