[refactor] playground p4

pull/2/head
q191201771 5 years ago
parent 3f0655567a
commit 0012c33084

@ -66,7 +66,7 @@ naza 即哪吒(正确拼音为 nezha我女儿发音读作 naza少一个
* pkg/snowflake [分布式ID生成算法snowflake介绍及Go语言实现](https://pengrl.com/p/20041/)
* pkg/bininfo [给Go程序加入编译版本时间等信息](https://pengrl.com/p/37397/)
* pkg/nazastring [`Go语言中[]byte和string类型相互转换时的性能分析和优化`](https://www.pengrl.com/p/31544/)
* pkg/nazastring [Go语言中[]byte和string类型相互转换时的性能分析和优化](https://www.pengrl.com/p/31544/)
* [Go创建对象时如何优雅的传递初始化参数](https://pengrl.com/p/60015/)
* playground/p3 [利用CPU cache特性优化Go程序](https://pengrl.com/p/9125/)

@ -32,13 +32,13 @@ func SearchWithLog(n int, f func(int) bool) int {
func main() {
const key = 3
//const key = 0
//const key = 2
//const key = 9
arr := []int{1, 3, 5, 7}
index := SearchWithLog(len(arr), func(i int) bool {
//return arr[i] == 3
//return arr[i] >= 3
return arr[i] >= key
//return arr[i] >= 9
//return arr[i] >= 2
})
fmt.Printf("index=%d\n", index)
if index < len(arr) && arr[index] == key {

Loading…
Cancel
Save