Trimming
Remove unwanted elements from the start, the end, or both ends of a collection.
Trimming Both Ends of a Collection
func trimming(while: (Element) throws -> Bool
) rethrows -> SubSequence Returns a
SubSequence
formed by discarding all elements at the start and end of the collection which satisfy the given predicate.func trim(while: (Element) throws -> Bool
) rethrows Mutates a
BidirectionalCollection
by discarding all elements at the start and at the end of it which satisfy the given predicate.func trim(while: (Element) throws -> Bool
) rethrows Mutates a
BidirectionalCollection
by discarding all elements at the start and at the end of it which satisfy the given predicate.
Trimming from the Start
Swift/Collection/trimmingPrefix(while:)
func trimPrefix(while: (Element) throws -> Bool
) rethrows Mutates a
Collection
by discarding all elements at the start of it which satisfy the given predicate.func trimPrefix(while: (Element) throws -> Bool
) rethrows Mutates a
Collection
by discarding all elements at the start of it which satisfy the given predicate.
Trimming from the End
func trimmingSuffix(while: (Element) throws -> Bool
) rethrows -> SubSequence Returns a
SubSequence
formed by discarding all elements at the end of the collection which satisfy the given predicate.func trimSuffix(while: (Element) throws -> Bool
) rethrows Mutates a
BidirectionalCollection
by discarding all elements at the end of it which satisfy the given predicate.func trimSuffix(while: (Element) throws -> Bool
) rethrows Mutates a
BidirectionalCollection
by discarding all elements at the end of it which satisfy the given predicate.
Finding the Suffix of a Collection
func suffix(while: (Element) throws -> Bool
) rethrows -> SubSequence Returns a subsequence containing the elements from the end until
predicate
returnsfalse
and skipping the remaining elements.
Finding Boundaries within a Collection
func endOfPrefix(while: (Element) throws -> Bool
) rethrows -> Index Returns the exclusive upper bound of the prefix of elements that satisfy the predicate.
func startOfSuffix(while: (Element) throws -> Bool
) rethrows -> Index Returns the inclusive lower bound of the suffix of elements that satisfy the predicate.