mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-13 07:04:44 +08:00
新增算法模块
This commit is contained in:
28
util/algorithms/BiSearch_test.go
Normal file
28
util/algorithms/BiSearch_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package algorithms
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type MyElement struct {
|
||||
Score int
|
||||
}
|
||||
|
||||
func (s MyElement) GetValue() int {
|
||||
return s.Score
|
||||
}
|
||||
|
||||
func Test_BiSearch(t *testing.T){
|
||||
var schedulePoolCfgList []MyElement = []MyElement{MyElement{10}, MyElement{12}, MyElement{14}, MyElement{16}} //
|
||||
index := BiSearch[int, MyElement](schedulePoolCfgList, 9, true)
|
||||
index = BiSearch[int, MyElement](schedulePoolCfgList, 10, true)
|
||||
index = BiSearch[int, MyElement](schedulePoolCfgList, 11, true)
|
||||
index = BiSearch[int, MyElement](schedulePoolCfgList, 12, true)
|
||||
index = BiSearch[int, MyElement](schedulePoolCfgList, 13, true)
|
||||
index = BiSearch[int, MyElement](schedulePoolCfgList, 14, true)
|
||||
index = BiSearch[int, MyElement](schedulePoolCfgList, 15, true)
|
||||
index = BiSearch[int, MyElement](schedulePoolCfgList, 16, true)
|
||||
index = BiSearch[int, MyElement](schedulePoolCfgList, 17, true)
|
||||
fmt.Println(index)
|
||||
}
|
||||
Reference in New Issue
Block a user