We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
下面是测试代码
package main import ( "fmt" "github.com/shopspring/decimal" mainlog "lightning-engine/log" skiplist2 "lightning-engine/pqueue/skiplist" "strconv" ) type entrust struct { Id string Amount decimal.Decimal } func (e *entrust) GetId() string { return e.Id } func (e *entrust) GetAmount() decimal.Decimal { return e.Amount } func (e *entrust) GetUserId() int64 { return 0 } func (e *entrust) SetAmount(a decimal.Decimal) { e.Amount = a } var skiplist *skiplist2.SkipList func main() { mainlog.InitLog() skiplist, _ = skiplist2.NewSkipList() add := 0 for z := 0; z < 2; z++ { for k := 0; k < 2; k++ { add = add + 10000 for i := 0; i < 10000; i++ { price := decimal.NewFromInt(int64(i)) e := &entrust{ Id: strconv.Itoa(i + add), Amount: price, } skiplist.Insert(price, e) } success := 0 failed := 0 for i := 0; i < 10000; i++ { price := decimal.NewFromInt(int64(i)) node, _ := skiplist.Find(price, strconv.Itoa(i+add)) if node == nil || !node.Score().Equal(price) { failed++ } else { success++ } } fmt.Println("success:", success, "failed:", failed) for i := 9999; i >= 0; i-- { price := decimal.NewFromInt(int64(i)) skiplist.Delete(price, strconv.Itoa(i+add)) //skiplist.Delete(decimal.NewFromInt(int64(i)), strconv.Itoa(i+add)) } if skiplist.GetSize() > 0 || skiplist.GetLevel() > 1 { fmt.Println("error", skiplist.GetSize(), skiplist.GetLevel()) } else { fmt.Println("success") } } for k := 0; k < 1; k++ { add = add + 10000 for i := 0; i < 10000; i++ { price := decimal.NewFromInt(int64(123)) e := &entrust{ Id: strconv.Itoa(i + add), Amount: decimal.NewFromInt(int64(123)), } skiplist.Insert(price, e) } success := 0 failed := 0 for i := 0; i < 10000; i++ { price := decimal.NewFromInt(int64(123)) node, _ := skiplist.Find(price, strconv.Itoa(i+add)) if node == nil || !node.Score().Equal(price) { failed++ } else { success++ } } fmt.Println("success:", success, "failed:", failed) for i := 9999; i >= 0; i-- { price := decimal.NewFromInt(int64(123)) skiplist.Delete(price, strconv.Itoa(i+add)) } if skiplist.GetSize() > 0 || skiplist.GetLevel() > 1 { fmt.Println("error", skiplist.GetSize(), skiplist.GetLevel()) } else { fmt.Println("success") } } } }
The text was updated successfully, but these errors were encountered:
解决了吗
Sorry, something went wrong.
No branches or pull requests
下面是测试代码
The text was updated successfully, but these errors were encountered: