A collection whose element type is Element
but that is always empty.
SDK
- Xcode 6.0.1+
Framework
- Swift Standard Library
A collection whose element type is Element
but that is always empty.
SDK
Framework
typealias Empty Collection .Index
A type that represents a valid position in the collection.
typealias Empty Collection .Indices
A type that represents the indices that are valid for subscripting the collection, in ascending order.
typealias Empty Collection .Sub Sequence
A sequence that represents a contiguous subrange of the collection’s elements.
init()
Creates an instance.
var count: Int
The number of elements (always zero).
var end Index: Empty Collection<Element>.Index
Always zero, just like start
.
var first: Element?
The first element of the collection.
var indices: Range<Int>
The indices that are valid for subscripting the collection, in ascending order.
var is Empty: Bool
A Boolean value indicating whether the collection is empty.
var last: Element?
The last element of the collection.
var lazy: Lazy Sequence<Empty Collection<Element>>
A sequence containing the same elements as this sequence, but on which some operations, such as map
and filter
, are implemented lazily.
var start Index: Empty Collection<Element>.Index
Always zero, just like end
.
var underestimated Count: Int
A value less than or equal to the number of elements in the collection.
func all Satisfy((Element) -> Bool) -> Bool
Returns a Boolean value indicating whether every element of a sequence satisfies a given predicate.
func compact Map<Element Of Result>((Element) -> Element Of Result?) -> [Element Of Result]
Returns an array containing the non-nil
results of calling the given transformation with each element of this sequence.
func contains(Element) -> Bool
Returns a Boolean value indicating whether the sequence contains the given element.
func contains(where: (Element) -> Bool) -> Bool
Returns a Boolean value indicating whether the sequence contains an element that satisfies the given predicate.
func difference<C>(from: C) -> Collection Difference<Element>
Returns the difference needed to produce this collection’s ordered elements from the given collection.
func difference<C>(from: C, by: (C .Element, Element) -> Bool) -> Collection Difference<Element>
Returns the difference needed to produce this collection’s ordered elements from the given collection, using the given predicate as an equivalence test.
func distance(from: Empty Collection<Element>.Index, to: Empty Collection<Element>.Index) -> Int
The distance between two indexes (always zero).
func drop(while: (Element) -> Bool) -> Empty Collection<Element>
Returns a subsequence by skipping elements while predicate
returns true
and returning the remaining elements.
func drop First(Int) -> Empty Collection<Element>
Returns a subsequence containing all but the given number of initial elements.
func drop Last(Int) -> Empty Collection<Element>
Returns a subsequence containing all but the specified number of final elements.
func elements Equal<Other Sequence>(Other Sequence) -> Bool
Returns a Boolean value indicating whether this sequence and another sequence contain the same elements in the same order.
func elements Equal<Other Sequence>(Other Sequence, by: (Element, Other Sequence .Element) -> Bool) -> Bool
Returns a Boolean value indicating whether this sequence and another sequence contain equivalent elements in the same order, using the given predicate as the equivalence test.
func enumerated() -> Enumerated Sequence<Empty Collection<Element>>
Returns a sequence of pairs (n, x), where n represents a consecutive integer starting at zero and x represents an element of the sequence.
func filter((Element) -> Bool) -> [Element]
Returns an array containing, in order, the elements of the sequence that satisfy the given predicate.
func first(where: (Element) -> Bool) -> Element?
Returns the first element of the sequence that satisfies the given predicate.
func first Index(of: Element) -> Int?
Returns the first index where the specified value appears in the collection.
func first Index(where: (Element) -> Bool) -> Int?
Returns the first index in which an element of the collection satisfies the given predicate.
func flat Map<Segment Of Result>((Element) -> Segment Of Result) -> [Segment Of Result .Element]
Returns an array containing the concatenated results of calling the given transformation with each element of this sequence.
func for Each((Element) -> Void)
Calls the given closure on each element in the sequence in the same order as a for
-in
loop.
func form Index(inout Int, offset By: Int)
Offsets the given index by the specified distance.
func form Index(inout Int, offset By: Int, limited By: Int) -> Bool
Offsets the given index by the specified distance, or so that it equals the given limiting index.
func form Index(after: inout Int)
Replaces the given index with its successor.
func form Index(before: inout Int)
Replaces the given index with its predecessor.
func index(Empty Collection<Element>.Index, offset By: Int) -> Empty Collection<Element>.Index
Returns an index that is the specified distance from the given index.
func index(Empty Collection<Element>.Index, offset By: Int, limited By: Empty Collection<Element>.Index) -> Empty Collection<Element>.Index?
Returns an index that is the specified distance from the given index, unless that distance is beyond a given limiting index.
func index(of: Element) -> Int?
Returns the first index where the specified value appears in the collection.
func index(where: (Element) -> Bool) -> Int?
Returns the first index in which an element of the collection satisfies the given predicate.
func joined() -> Flatten Sequence<Empty Collection<Element>>
Returns the elements of this sequence of sequences, concatenated.
func joined<Separator>(separator: Separator) -> Joined Sequence<Empty Collection<Element>>
Returns the concatenated elements of this sequence of sequences, inserting the given separator between each element.
func joined(separator: String) -> String
Returns a new string by concatenating the elements of the sequence, adding the given separator between each element.
func joined(separator: String) -> String
Returns a new string by concatenating the elements of the sequence, adding the given separator between each element.
func last(where: (Element) -> Bool) -> Element?
Returns the last element of the sequence that satisfies the given predicate.
func last Index(of: Element) -> Int?
Returns the last index where the specified value appears in the collection.
func last Index(where: (Element) -> Bool) -> Int?
Returns the index of the last element in the collection that matches the given predicate.
func lexicographically Precedes<Other Sequence>(Other Sequence) -> Bool
Returns a Boolean value indicating whether the sequence precedes another sequence in a lexicographical (dictionary) ordering, using the less-than operator (<
) to compare elements.
func lexicographically Precedes<Other Sequence>(Other Sequence, by: (Element, Element) -> Bool) -> Bool
Returns a Boolean value indicating whether the sequence precedes another sequence in a lexicographical (dictionary) ordering, using the given predicate to compare elements.
func make Iterator() -> Empty Collection<Element>.Iterator
Returns an empty iterator.
func map<T>((Element) -> T) -> [T]
Returns an array containing the results of mapping the given closure over the sequence’s elements.
func max() -> Element?
Returns the maximum element in the sequence.
func max(by: (Element, Element) -> Bool) -> Element?
Returns the maximum element in the sequence, using the given predicate as the comparison between elements.
func min() -> Element?
Returns the minimum element in the sequence.
func min(by: (Element, Element) -> Bool) -> Element?
Returns the minimum element in the sequence, using the given predicate as the comparison between elements.
func partition(by: (Element) -> Bool) -> Int
Reorders the elements of the collection such that all the elements that match the given predicate are after all the elements that don’t match.
func pop First() -> Element?
Removes and returns the first element of the collection.
func pop Last() -> Element?
Removes and returns the last element of the collection.
func prefix(Int) -> Empty Collection<Element>
Returns a subsequence, up to the specified maximum length, containing the initial elements of the collection.
func prefix(through: Int) -> Empty Collection<Element>
Returns a subsequence from the start of the collection through the specified position.
func prefix(up To: Int) -> Empty Collection<Element>
Returns a subsequence from the start of the collection up to, but not including, the specified position.
func prefix(while: (Element) -> Bool) -> Empty Collection<Element>
Returns a subsequence containing the initial elements until predicate
returns false
and skipping the remaining elements.
func random Element() -> Element?
Returns a random element of the collection.
func random Element<T>(using: inout T) -> Element?
Returns a random element of the collection, using the given generator as a source for randomness.
func reduce<Result>(Result, (Result, Element) -> Result) -> Result
Returns the result of combining the elements of the sequence using the given closure.
func reduce<Result>(into: Result, (inout Result, Element) -> ()) -> Result
Returns the result of combining the elements of the sequence using the given closure.
func remove First() -> Element
Removes and returns the first element of the collection.
func remove First(Int)
Removes the specified number of elements from the beginning of the collection.
func remove Last() -> Element
Removes and returns the last element of the collection.
func remove Last(Int)
Removes the given number of elements from the end of the collection.
func reverse()
Reverses the elements of the collection in place.
func reversed() -> Reversed Collection<Empty Collection<Element>>
Returns a view presenting the elements of the collection in reverse order.
func shuffle()
Shuffles the collection in place.
func shuffle<T>(using: inout T)
Shuffles the collection in place, using the given generator as a source for randomness.
func shuffled() -> [Element]
Returns the elements of the sequence, shuffled.
func shuffled<T>(using: inout T) -> [Element]
Returns the elements of the sequence, shuffled using the given generator as a source for randomness.
func sort()
Sorts the collection in place.
func sort(by: (Element, Element) -> Bool)
Sorts the collection in place, using the given predicate as the comparison between elements.
func sorted() -> [Element]
Returns the elements of the sequence, sorted.
func sorted(by: (Element, Element) -> Bool) -> [Element]
Returns the elements of the sequence, sorted using the given predicate as the comparison between elements.
func split(max Splits: Int, omitting Empty Subsequences: Bool, where Separator: (Element) -> Bool) -> [Empty Collection<Element>]
Returns the longest possible subsequences of the collection, in order, that don’t contain elements satisfying the given predicate.
func split(separator: Element, max Splits: Int, omitting Empty Subsequences: Bool) -> [Empty Collection<Element>]
Returns the longest possible subsequences of the collection, in order, around elements equal to the given element.
func split(separator: Element, max Splits: Int, omitting Empty Subsequences: Bool) -> [Array Slice<Element>]
Returns the longest possible subsequences of the sequence, in order, around elements equal to the given element.
func starts<Possible Prefix>(with: Possible Prefix) -> Bool
Returns a Boolean value indicating whether the initial elements of the sequence are the same as the elements in another sequence.
func starts<Possible Prefix>(with: Possible Prefix, by: (Element, Possible Prefix .Element) -> Bool) -> Bool
Returns a Boolean value indicating whether the initial elements of the sequence are equivalent to the elements in another sequence, using the given predicate as the equivalence test.
func suffix(Int) -> Empty Collection<Element>
Returns a subsequence, up to the given maximum length, containing the final elements of the collection.
func suffix(from: Int) -> Empty Collection<Element>
Returns a subsequence from the specified position to the end of the collection.
func swap At(Int, Int)
Exchanges the values at the specified indices of the collection.
func with Contiguous Mutable Storage If Available<R>((inout Unsafe Mutable Buffer Pointer<Element>) -> R) -> R?
Call body(p)
, where p
is a pointer to the collection’s mutable contiguous storage. If no such storage exists, it is first created. If the collection does not support an internal representation in a form of mutable contiguous storage, body
is not called and nil
is returned.
func with Contiguous Storage If Available<R>((Unsafe Buffer Pointer<Element>) -> R) -> R?
Call body(p)
, where p
is a pointer to the collection’s contiguous storage. If no such storage exists, it is first created. If the collection does not support an internal representation in a form of contiguous storage, body
is not called and nil
is returned.
subscript(Empty Collection<Element>.Index) -> Element
Accesses the element at the given position.
subscript(Range<Empty Collection<Element>.Index>) -> Empty Collection<Element>.Sub Sequence
Accesses a contiguous subrange of the collection’s elements.
subscript(Range<Int>) -> Slice<Empty Collection<Element>>
Accesses a contiguous subrange of the collection’s elements.
subscript<R>(R) -> Empty Collection<Element>
Accesses the contiguous subrange of the collection’s elements specified by a range expression.
static func != (Empty Collection<Element>, Empty Collection<Element>) -> Bool
Returns a Boolean value indicating whether two values are not equal.
static func == (Empty Collection<Element>, Empty Collection<Element>) -> Bool
Returns a Boolean value indicating whether two values are equal.
struct Empty Collection .Iterator
An iterator that never produces an element.
func repeat Element<T>(T, count: Int) -> Repeated<T>
Creates a collection containing the specified number of the given element.
struct Collection Of One
A collection containing a single element.
struct Key Value Pairs
A lightweight collection of key-value pairs.
typealias Dictionary Literal
Deprecated