CircularBuffer (ext)
You’re viewing third-party extensions to CircularBuffer, a struct from swift-nio.
You can also read the documentation forCircularBuffer itself.
extension CircularBufferYou’re viewing third-party extensions to CircularBuffer, a struct from swift-nio.
You can also read the documentation forCircularBuffer itself.
extension CircularBufferstruct CircularBuffer<Element>An automatically expanding ring buffer implementation backed by a ContiguousArray. Even though this implementation will automatically expand if more elements than initialCapacity are stored, it’s advantageous to prevent expansions from happening frequently. Expansions will always force an allocation and a copy to happen.
import VaporVapor 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.
protocol CopyableA type whose values can be implicitly or explicitly copied.
protocol Escapablevar hex: String { get }var string: String { get }Converts an array of PathComponent into a readable path string.
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 EventLoopFutures 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 hexEncodedBytes(uppercase: Bool = false) -> [UInt8] func hexEncodedBytes(uppercase: Bool = false) -> [UInt8] func hexEncodedString(uppercase: Bool = false) -> String 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 joined<Separator>(by separator: Separator) -> JoinedBySequence<Self, Separator> where Separator : Collection, Separator.Element == Self.Element.Element Returns the concatenation of the elements in this sequence of sequences, inserting the given separator between each sequence.
func joined(by separator: Element.Element) -> JoinedBySequence<Self, CollectionOfOne<Element.Element>> Returns the concatenation of the elements in this sequence of sequences, inserting the given separator between each sequence.
func joined<Separator>(by separator: (Element, Element) throws -> Separator) rethrows -> [Element.Element] where Separator : Sequence, Separator.Element == Self.Element.Element Returns the concatenation of the elements in this sequence of sequences, inserting the separator produced by the closure between each sequence.
func joined(by separator: (Element, Element) throws -> Element.Element) rethrows -> [Element.Element] Returns the concatenation of the elements in this sequence of sequences, inserting the separator produced by the closure between each sequence.
func joined<Separator>(by separator: Separator) -> JoinedByCollection<Self, Separator> where Separator : Collection, Separator.Element == Self.Element.Element Returns the concatenation of the elements in this collection of collections, inserting the given separator between each collection.
func joined(by separator: Element.Element) -> JoinedByCollection<Self, CollectionOfOne<Element.Element>> Returns the concatenation of the elements in this collection of collections, inserting the given separator between each collection.
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) -> [Element] Returns the largest elements of this sequence.
func max(count: Int) -> [Element] Returns the largest elements of this collection.
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) -> [Element] Returns the smallest elements of this sequence.
func min(count: Int) -> [Element] Returns the smallest elements of this collection.
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() -> (min: Element, max: Element)? Returns both the minimum and maximum elements in the sequence.
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.
mutating func partition(subrange: Range<Index>, by belongsInSecondPartition: (Element) throws -> Bool) rethrows -> Index Moves all elements satisfying isSuffixElement into a suffix of the collection, returning the start position of the resulting suffix.
mutating func partition(subrange: Range<Index>, by belongsInSecondPartition: (Element) throws -> Bool) rethrows -> Index Moves all elements satisfying isSuffixElement into a suffix of the collection, returning the start position of the resulting suffix.
func partitioned(by predicate: (Element) throws -> Bool) rethrows -> (falseElements: [Element], trueElements: [Element]) Returns two arrays containing the elements of the collection that don’t and do satisfy the given predicate, respectively.
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.
mutating func reverse(subrange: Range<Index>) Reverses the elements within the given subrange.
@discardableResult mutating func rotate(subrange: Range<Index>, toStartAt newStart: Index) -> Index Rotates the elements within the given subrange so that the element at the specified index becomes the start of the subrange.
@discardableResult mutating func rotate(subrange: Range<Index>, toStartAt newStart: Index) -> Index Rotates the elements within the given subrange so that the element at the specified index becomes the start of the subrange.
@discardableResult mutating func rotate(toStartAt newStart: Index) -> Index Rotates the elements of this collection so that the element at the specified index becomes the start of the collection.
@discardableResult mutating func rotate(toStartAt newStart: Index) -> Index Rotates the elements of this collection so that the element at the specified index becomes the start of the collection.
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.
mutating func stablePartition(by belongsInSecondPartition: (Element) throws -> Bool) rethrows -> Index Moves all elements satisfying the given predicate into a suffix of this collection, preserving the relative order of the elements in both partitions, and returns the start of the resulting suffix.
mutating func stablePartition(subrange: Range<Index>, by belongsInSecondPartition: (Element) throws -> Bool) rethrows -> Index Moves all elements satisfying the given predicate into a suffix of the given range, preserving the relative order of the elements in both partitions, and returns the start of the resulting suffix.
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.
mutating func trim(while predicate: (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.
mutating func trim(while predicate: (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.
mutating func trimPrefix(while predicate: (Element) throws -> Bool) rethrows Mutates a Collection by discarding all elements at the start of it which satisfy the given predicate.
mutating func trimPrefix(while predicate: (Element) throws -> Bool) rethrows Mutates a Collection by discarding all elements at the start of it which satisfy the given predicate.
mutating func trimSuffix(while predicate: (Element) throws -> Bool) rethrows Mutates a BidirectionalCollection by discarding all elements at the end of it which satisfy the given predicate.
mutating func trimSuffix(while predicate: (Element) throws -> Bool) rethrows Mutates a BidirectionalCollection by discarding all elements at the end of it which satisfy the given predicate.
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 uniquePermutations(ofCount k: Int? = nil) -> UniquePermutationsSequence<Self> Returns a sequence of the unique permutations of this sequence of the specified length.
func uniquePermutations<R>(ofCount kRange: R) -> UniquePermutationsSequence<Self> where R : RangeExpression, R.Bound == Int Returns a collection of the unique permutations of this sequence with lengths in the specified range.
func uniqued() -> UniquedSequence<Self, Element> Returns a sequence with only the unique elements of this sequence, in the order of the first occurrence of each unique element.
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]