public protocol _ShapedArrayProtocol
  : RandomAccessCollection, MutableCollection
  • Declaration

    associatedtype Scalar
  • The number of dimensions of the array.

    Declaration

    var rank: Int { get }
  • The dimensions of the array.

    Declaration

    var shape: [Int] { get }
  • The total number of scalars in the array.

    Declaration

    var scalarCount: Int { get }
  • Creates an array with the specified shape and contiguous scalars in row-major order.

    Precondition

    The number of scalars must equal the product of the dimensions of the shape.

    Declaration

    init(shape: [Int], scalars: [Scalar])
  • Creates an array with the specified shape and sequence of scalars in row-major order.

    Precondition

    The number of scalars must equal the product of the dimensions of the shape.

    Declaration

    init<S>(shape: [Int], scalars: S) where S : Sequence, Self.Scalar == S.Element
  • Calls a closure with a pointer to the array’s contiguous storage.

    Declaration

    func withUnsafeBufferPointer<R>(_ body: (UnsafeBufferPointer<Scalar>) throws -> R) rethrows -> R

    Parameters

    body

    A closure with an UnsafeBufferPointer parameter that points to the contiguous storage for the array. If no such storage exists, it is created. If body has a return value, that value is also used as the return value for the withUnsafeBufferPointer(_:) method. The pointer argument is valid only for the duration of the method’s execution.

  • Calls the given closure with a pointer to the array’s mutable contiguous storage.

    Declaration

    mutating func withUnsafeMutableBufferPointer<R>(_ body: (inout UnsafeMutableBufferPointer<Scalar>) throws -> R) rethrows -> R

    Parameters

    body

    A closure with an UnsafeMutableBufferPointer parameter that points to the contiguous storage for the array. If no such storage exists, it is created. If body has a return value, that value is also used as the return value for the withUnsafeMutableBufferPointer(_:) method. The pointer argument is valid only for the duration of the method’s execution.

  • scalars

    Extension method

    The scalars of the array in row-major order.

    Declaration

    var scalars: [Scalar] { get set }
  • isScalar

    Extension method

    Returns true if the array has rank 0.

    Declaration

    var isScalar: Bool { get }
  • scalar

    Extension method

    Returns the single scalar element if the array has rank 0 and nil otherwise.

    Declaration

    var scalar: Scalar? { get }
  • ==(_:_:)

    Extension method

    Declaration

    static func == <Other>(lhs: Self, rhs: Other) -> Bool
      where Other : _ShapedArrayProtocol, Scalar == Other.Scalar
  • count

    Extension method

    Returns the number of element arrays in an array (equivalent to the first dimension).

    Note

    count is distinct from scalarCount, which represents the total number of scalars.

    Declaration

    var count: Int { get }