gpt4 book ai didi

swift - --> (dash dash greater than) 运算符在 Swift 中是什么意思

转载 作者:搜寻专家 更新时间:2023-10-31 08:17:42 28 4
gpt4 key购买 nike

我看GPUImage2的源码

    picture = PictureInput(image:UIImage(named:"WID-small.jpg")!)
filter = SaturationAdjustment()
picture --> filter --> renderView
picture.processImage()

--> 是做什么的?

最佳答案

这是一个声明为将目标添加到源的运算符。

infix operator --> : AdditionPrecedence
//precedencegroup ProcessingOperationPrecedence {
// associativity: left
//// higherThan: Multiplicative
//}
@discardableResult public func --><T:ImageConsumer>(source:ImageSource, destination:T) -> T {
source.addTarget(destination)
return destination
}

函数在pipeline.swift文件中声明

addTarget 函数也非常 self 描述。

public func addTarget(_ target:ImageConsumer, atTargetIndex:UInt? = nil) {
if let targetIndex = atTargetIndex {
target.setSource(self, atIndex:targetIndex)
targets.append(target, indexAtTarget:targetIndex)
transmitPreviousImage(to:target, atIndex:targetIndex)
} else if let indexAtTarget = target.addSource(self) {
targets.append(target, indexAtTarget:indexAtTarget)
transmitPreviousImage(to:target, atIndex:indexAtTarget)
} else {
debugPrint("Warning: tried to add target beyond target's input capacity")
}
}

编辑 正如其他人所说,运算符(operator)是该项目的自定义运算符(operator),截至 2018 年 3 月 29 日,该运算符(operator)并未内置在 swift 语言中

关于swift - --> (dash dash greater than) 运算符在 Swift 中是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42478881/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com