From 0012c33084b6ee906f300f4f56bd4f4bf03f374e Mon Sep 17 00:00:00 2001 From: q191201771 <191201771@qq.com> Date: Sat, 11 Jan 2020 11:49:41 +0800 Subject: [PATCH] [refactor] playground p4 --- README.md | 2 +- playground/p4/p4.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8d02055..8fedd68 100644 --- a/README.md +++ b/README.md @@ -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/) diff --git a/playground/p4/p4.go b/playground/p4/p4.go index d35c669..7d1b547 100644 --- a/playground/p4/p4.go +++ b/playground/p4/p4.go @@ -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 {