EntityCollection

public struct EntityCollection<T> where T : Hashable

An observable collection of Entity instances where each entity has a unique id.

  • Implemented by subclasses to initialize a new object (the receiver) immediately after memory for it has been allocated.

    Declaration

    Swift

    init()
  • Creates a new instance with the specified sequence of the generic type.

    Declaration

    Swift

    init<S>(_ sequence: S) where T == S.Element, S : Sequence

    Parameters

    sequence

    The sequence to use for the new instance.

  • Creates a new instance with the specified sequence of the generic type.

    Declaration

    Swift

    init<S>(_ sequence: S) where S : Sequence, S.Element == (key: T, value: Any)

    Parameters

    sequence

    The sequence to use for the new instance.

  • A collection containing the values of the EntityCollection.

    Declaration

    Swift

    public var values: [T] { get }
  • Adds an element to the contents of EntityCollection.

    Declaration

    Swift

    public mutating func add(value: Any? = nil, forKey key: T)

    Parameters

    value

    The object to store in the contents of EntityCollection.

    key

    The key with which to associate the value.

  • A textual representation of this instance.

    Declaration

    Swift

    public var description: String { get }
  • A textual representation of this instance, suitable for debugging.

    Declaration

    Swift

    public var debugDescription: String { get }
  • Creates a new instance with the specified array literal.

    Declaration

    Swift

    public init(arrayLiteral elements: T...)

    Parameters

    elements

    Elements to be stored in a EntityCollection.

  • Creates a new instance with the specified dictionary literal.

    Declaration

    Swift

    public init(dictionaryLiteral elements: (T, Any)...)

    Parameters

    elements

    Elements to be stored in a EntityCollection.

  • Type to mean instance of AnyIterator.

    Declaration

    Swift

    public typealias Iterator = AnyIterator<(element: T, value: Any)>
  • Returns an iterator over the elements of the collection.

    Declaration

    Swift

    public func makeIterator() -> Iterator

    Return Value

    Advances to the next element and returns it, or nil if no next element exists.

  • Type to mean instance of DictionaryIndex.

    Declaration

    Swift

    public typealias Index = EntityCollectionIndex<T>
  • The position of the first element in a nonempty dictionary.

    Declaration

    Swift

    public var startIndex: Index { get }
  • The dictionary’s “past the end” position—that is, the position one greater than the last valid subscript argument.

    Declaration

    Swift

    public var endIndex: Index { get }
  • Returns an element where the given element is contained within the range expression.

    Declaration

    Swift

    public subscript(position: Index) -> Iterator.Element { get }

    Parameters

    position

    The index value of contents of EntityCollection.

  • Returns the position immediately after the given index.

    Declaration

    Swift

    public func index(after i: Index) -> Index

    Parameters

    i

    A valid index of the collection. i must be less than endIndex.

    Return Value

    The index value immediately after i.