Other Protocols

The following protocols are available globally.

Queue

  • A first-in-first-out data structure.

    See more

    Declaration

    Swift

    public protocol Queue
  • Classes having initializers that actually create derived classes.

    To use, make your class conform and forward to init(aliasing:) or init(unsafelyAliasing:) from a convenience init:

    public 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())
      }
    }
    
    See more

    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 of inserting/removing, you probably want to use RandomAccessCollection/MutableCollection (either as constraints or conformances).

    The models of FixedSizeArray defined here efficiently support producing new instances by single-element insertion and deletion.

    See more

    Declaration

    Swift

    public protocol FixedSizeArray:
      MutableCollection, RandomAccessCollection, SourceInitializableCollection,
      CustomStringConvertible where Index == Int

Priority Queue

  • Undocumented

    See more

    Declaration

    Swift

    public protocol IndexProtocol
  • Indexes from Key to Value.

    See also

    IndexProtocol.

    Note

    this is intentionally distinct from IndexProtocol, in order to statically disallow PriorityQueue’s reprioritization APIs when using a NonIndexingPriorityQueueIndexer indexer.
    See more

    Declaration

    Swift

    public protocol PriorityQueueIndexer
  • An ID that can also be used as an index into a dense, contiguous array.

    See more

    Declaration

    Swift

    public protocol IdIndexable
  • KeyPaths with a statically known Value endpoint.

    This protocol allows us to create the constraint that some Lens‘s Focus is-an instance of KeyPath. For example:

    public struct X<T, L: Lens> where L.Focus: KeyPath<T, L.Value> { ... }
                                                            ^^^^^
    
    See more

    Declaration

    Swift

    public protocol KeyPathProtocol : AnyKeyPath
  • Types that represent, in the type system, a specific key path value.

    A given Lens-conforming type’s associated key path value is provided by its static var focus.

    See more

    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 TupleProtocol don’t have those problems.

    See more