Other Protocols
The following protocols are available globally.
-
A type is
See moreDefaultInitializable
as long as it can be initialized with no parameters.Declaration
Swift
public protocol DefaultInitializable
-
A first-in-first-out data structure.
See moreDeclaration
Swift
public protocol Queue
-
Classes having initializers that actually create derived classes.
To use, make your class conform and forward to
init(aliasing:)
orinit(unsafelyAliasing:)
from aconvenience init
:
See morepublic class Base : FactoryInitializable { /// Constructs an instance whose dynamic type depends on the value of `one` public convenience init(_ one: Bool) { self.init(aliasing: one ? Derived1() : Derived2()) } }
Declaration
Swift
public protocol FactoryInitializable
-
Statically-sized nonempty collections of homogeneous elements.
This protocol is mostly an implementation detail of
ArrayN
; it is not generally useful. Unless you’re interested in generic application ofinserting
/removing
, you probably want to useRandomAccessCollection
/MutableCollection
(either as constraints or conformances).The models of
See moreFixedSizeArray
defined here efficiently support producing new instances by single-element insertion and deletion.Declaration
Swift
public protocol FixedSizeArray: MutableCollection, RandomAccessCollection, SourceInitializableCollection, CustomStringConvertible where Index == Int
-
Undocumented
See moreDeclaration
Swift
public protocol IndexProtocol
-
Indexes from
Key
toValue
.See also
IndexProtocol
.Note
this is intentionally distinct fromIndexProtocol
, in order to statically disallow PriorityQueue’s reprioritization APIs when using aNonIndexingPriorityQueueIndexer
indexer.Declaration
Swift
public protocol PriorityQueueIndexer
-
An ID that can also be used as an index into a dense, contiguous array.
See moreDeclaration
Swift
public protocol IdIndexable
-
KeyPath
s with a statically knownValue
endpoint.This protocol allows us to create the constraint that some
Lens
‘sFocus
is-an instance ofKeyPath
. For example:
See morepublic struct X<T, L: Lens> where L.Focus: KeyPath<T, L.Value> { ... } ^^^^^
Declaration
Swift
public protocol KeyPathProtocol : AnyKeyPath
-
Types that represent, in the type system, a specific key path value.
A given
See moreLens
-conforming type’s associated key path value is provided by itsstatic var focus
.Declaration
Swift
public protocol Lens
-
A collection that can be initialized to contain exactly the elements of a source collection.
See more -
Generalized algebraic product types
Swift’s built-in tuple types are algebraic product types, but since they are not nominal and not easily decomposed, they don’t lend themselves to many types of useful processing. Models of
See moreTupleProtocol
don’t have those problems.