Runs (ext)
You’re viewing third-party extensions to AttributedString.Runs
, a struct from the Swift standard library.
You can also read the documentation forAttributedString.Runs
itself.
extension Runs
You’re viewing third-party extensions to AttributedString.Runs
, a struct from the Swift standard library.
You can also read the documentation forAttributedString.Runs
itself.
extension Runs
@dynamicMemberLookup struct AttributedString
struct Runs
import Vapor
Vapor is a framework for building server applications, APIs and websites in Swift. It provides a safe, performant and scalable foundation for building large complex backends.
func adjacentPairs() -> AdjacentPairsCollection<Self>
Returns a collection of overlapping adjacent pairs of the elements of this collection.
func chunked(by belongInSameGroup: (Element, Element) throws -> Bool) rethrows -> [SubSequence]
Returns a collection of subsequences of this collection, chunked by the given predicate.
func chunked<Subject>(on projection: (Element) throws -> Subject) rethrows -> [(Subject, SubSequence)] where Subject : Equatable
Returns a collection of subsequences of this collection, chunked by grouping elements that project to equal values.
func chunks(ofCount count: Int) -> ChunksOfCountCollection<Self>
Returns a collection of subsequences, each with up to the specified length.
func combinations(ofCount k: Int) -> CombinationsSequence<Self>
Returns a collection of combinations of this collection’s elements, with each combination having the specified number of elements.
func compacted<Unwrapped>() -> CompactedSequence<Self, Unwrapped> where Self.Element == Unwrapped?
Returns a new Sequence
that iterates over every non-nil element from the original Sequence
.
func compacted<Unwrapped>() -> CompactedCollection<Self, Unwrapped> where Self.Element == Unwrapped?
Returns a new Collection
that iterates over every non-nil element from the original Collection
.
func cycled() -> CycledSequence<Self>
Returns a sequence that repeats the elements of this collection forever.
func cycled(times: Int) -> CycledTimesCollection<Self>
Returns a sequence that repeats the elements of this collection the specified number of times.
func endOfPrefix(while predicate: (Element) throws -> Bool) rethrows -> Index
Returns the exclusive upper bound of the prefix of elements that satisfy the predicate.
func evenlyChunked(in count: Int) -> EvenlyChunkedCollection<Self>
Returns a collection of evenly divided consecutive subsequences of this collection.
func firstNonNil<Result>(_ transform: (Element) throws -> Result?) rethrows -> Result?
Returns the first non-nil
result obtained from applying the given transformation to the elements of the sequence.
func flatten<Value>(on eventLoop: EventLoop) -> EventLoopFuture<[Value]> where Self.Element == EventLoopFuture<Value>
Converts a collection of EventLoopFuture
s to an EventLoopFuture
that wraps an array with the future values.
func grouped<GroupKey>(by keyForValue: (Element) throws -> GroupKey) rethrows -> [GroupKey : [Element]] where GroupKey : Hashable
Groups up elements of self
into a new Dictionary, whose values are Arrays of grouped elements, each keyed by the group key returned by the given closure.
func indexed() -> IndexedCollection<Self>
Returns a collection of pairs (i, x), where i represents an index of the collection, and x represents an element.
func interspersed(with separator: Element) -> InterspersedSequence<Self>
Returns a sequence containing elements of this sequence with the given separator inserted in between each element.
func keyed<Key>(by keyForValue: (Element) throws -> Key) rethrows -> [Key : Element] where Key : Hashable
Creates a new Dictionary from the elements of self
, keyed by the results returned by the given keyForValue
closure.
func keyed<Key>(by keyForValue: (Element) throws -> Key, resolvingConflictsWith resolve: (Key, Element, Element) throws -> Element) rethrows -> [Key : Element] where Key : Hashable
Creates a new Dictionary from the elements of self
, keyed by the results returned by the given keyForValue
closure. As the dictionary is built, the initializer calls the resolve
closure with the current and new values for any duplicate keys. Pass a closure as resolve
that returns the value to use in the resulting dictionary: The closure can choose between the two values, combine them to produce a new value, or even throw an error.
func max(count: Int, sortedBy areInIncreasingOrder: (Element, Element) throws -> Bool) rethrows -> [Element]
Returns the largest elements of this collection, as sorted by the given predicate.
func min(count: Int, sortedBy areInIncreasingOrder: (Element, Element) throws -> Bool) rethrows -> [Element]
Returns the smallest elements of this collection, as sorted by the given predicate.
func minAndMax(by areInIncreasingOrder: (Element, Element) throws -> Bool) rethrows -> (min: Element, max: Element)?
Returns both the minimum and maximum elements in the sequence, using the given predicate as the comparison between elements.
func partitioned(by predicate: (Element) throws -> Bool) rethrows -> (falseElements: [Element], trueElements: [Element])
Returns two arrays containing, in order, the elements of the collection that do and don’t satisfy the given predicate.
func partitioningIndex(where belongsInSecondPartition: (Element) throws -> Bool) rethrows -> Index
Returns the start index of the partition of a collection that matches the given predicate.
func permutations(ofCount k: Int? = nil) -> PermutationsSequence<Self>
Returns a collection of the permutations of this collection of the specified length.
func randomSample(count k: Int) -> [Element]
Randomly selects the specified number of elements from this collection.
func randomSample<G>(count k: Int, using rng: inout G) -> [Element] where G : RandomNumberGenerator
Randomly selects the specified number of elements from this sequence.
func randomSample<G>(count k: Int, using rng: inout G) -> [Element] where G : RandomNumberGenerator
Randomly selects the specified number of elements from this collection.
func randomStableSample(count k: Int) -> [Element]
Randomly selects the specified number of elements from this collection, maintaining their relative order.
func randomStableSample<G>(count k: Int, using rng: inout G) -> [Element] where G : RandomNumberGenerator
Randomly selects the specified number of elements from this collection, maintaining their relative order.
func reductions(_ transform: (Element, Element) throws -> Element) rethrows -> [Element]
Returns an array containing the accumulated results of combining the elements of the sequence using the given closure.
func reductions<Result>(_ initial: Result, _ transform: (Result, Element) throws -> Result) rethrows -> [Result]
Returns an array containing the accumulated results of combining the elements of the sequence using the given closure.
func reductions<Result>(into initial: Result, _ transform: (inout Result, Element) throws -> Void) rethrows -> [Result]
Returns an array containing the accumulated results of combining the elements of the sequence using the given closure.
func secureCompare<C>(to other: C) -> Bool where C : Collection, Self.Element == C.Element
Performs a full-comparison of all elements in two collections. If the two collections have a different number of elements, the function will compare all elements in the smaller collection first and then return false.
func sequencedFlatMapEach(on eventLoop: EventLoop, _ transform: @escaping (_ element: Element) -> EventLoopFuture<Void>) -> EventLoopFuture<Void>
An overload of sequencedFlatMapEach(on:_:)
which returns a Void
future instead of [Void]
when the result type of the transform closure is Void
.
func sequencedFlatMapEachCompact<Result>(on eventLoop: EventLoop, _ transform: @escaping (_ element: Element) -> EventLoopFuture<Result?>) -> EventLoopFuture<[Result]>
Variant of sequencedFlatMapEach(on:_:)
which provides compactMap()
semantics by allowing result values to be nil
. Such results are not included in the output array.
func startOfSuffix(while predicate: (Element) throws -> Bool) rethrows -> Index
Returns the inclusive lower bound of the suffix of elements that satisfy the predicate.
func striding(by step: Int) -> StridingCollection<Self>
Returns a sequence stepping through the elements every step
starting at the first value. Any remainders of the stride will be trimmed.
func suffix(while predicate: (Element) throws -> Bool) rethrows -> SubSequence
Returns a subsequence containing the elements from the end until predicate
returns false
and skipping the remaining elements.
func trimming(while predicate: (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 trimmingSuffix(while predicate: (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 uniqued<Subject>(on projection: (Element) throws -> Subject) rethrows -> [Element] where Subject : Hashable
Returns an array with the unique elements of this sequence (as determined by the given projection), in the order of the first occurrence of each unique element.
func windows(ofCount count: Int) -> WindowsOfCountCollection<Self>
Returns a collection of all the overlapping slices of a given size.
func scan(_ transform: (Element, Element) throws -> Element) rethrows -> [Element]
func scan<Result>(_ initial: Result, _ transform: (Result, Element) throws -> Result) rethrows -> [Result]
func scan<Result>(into initial: Result, _ transform: (inout Result, Element) throws -> Void) rethrows -> [Result]