如何确定切片中存在的元素的位置?
我需要以下内容:
type intSlice []int
func (slice intSlice) pos(value int) int {
for p, v := range slice {
if (v == value) {
return p
}
}
return -1
}
Run Code Online (Sandbox Code Playgroud) 我可以使用多少goroutines无痛?例如维基百科说,在Erlang中,可以创建2000万个进程,而不会降低性能.
更新:我刚刚调查了goroutines性能并得到了这样的结果:
我想将clicked()按钮中的信号连接到不同对象的插槽.
目前我将信号连接到辅助方法并从那里调用所需的插槽:
connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
void buttonClicked() { // Helper method. I'd like to avoid it.
someObject.desiredSlot(localFunc1(), localFunc2());
}
Run Code Online (Sandbox Code Playgroud)
但也许有一种更简单明了的方法可以做到这一点?