NSDictionary (ext)
You’re viewing third-party extensions to NSDictionary
, a class from the Swift standard library.
You can also read the documentation forNSDictionary
itself.
extension NSDictionary
You’re viewing third-party extensions to NSDictionary
, a class from the Swift standard library.
You can also read the documentation forNSDictionary
itself.
extension NSDictionary
class NSDictionary
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() -> AdjacentPairsSequence<Self>
Returns a sequence of overlapping adjacent pairs of the elements of this sequence.
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 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 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 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 sequence, as sorted by the given predicate.
func min(count: Int, sortedBy areInIncreasingOrder: (Element, Element) throws -> Bool) rethrows -> [Element]
Returns the smallest elements of this sequence, 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 sequence that do and don’t satisfy the given predicate.
func randomSample(count k: Int) -> [Element]
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 sequence.
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 striding(by step: Int) -> StridingSequence<Self>
Returns a sequence stepping through the elements every step
starting at the first value. Any remainders of the stride will be trimmed.
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 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]