当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Swift SIMD8 replacing(with:where:)用法及代码示例


用法一

实例方法

replacing(with:where:)

返回此向量的副本,其中 masktrue 的通道中的元素替换为 other 的元素。

声明

func replacing(
    with other: Self,
    where mask: SIMDMask<Self.MaskStorage>
) -> Self

详述

相当于:


var result = Self()
for i in indices {
  result[i] = mask[i] ? other[i] : self[i]
}

可用版本

iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+

用法二

实例方法

replacing(with:where:)

返回此向量的副本,其中 masktrue 的通道中包含元素 other

声明

func replacing(
    with other: Self.Scalar,
    where mask: SIMDMask<Self.MaskStorage>
) -> Self

详述

相当于:


var result = Self()
for i in indices {
  result[i] = mask[i] ? other : self[i]
}

可用版本

iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+

相关用法


注:本文由纯净天空筛选整理自apple.com大神的英文原创作品 SIMD8 replacing(with:where:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。