Skip to content
This repository was archived by the owner on Mar 8, 2024. It is now read-only.

Commit db5792b

Browse files
committed
fix a bug
1 parent 9ea95eb commit db5792b

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

indexes.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,24 @@ type dataItem = btree.Item
1919
type indexItem [4]uint32
2020

2121
func (i indexItem) Less(than btree.Item) bool {
22-
// 1:End < 0:Start
23-
return i[1] < than.(indexItem)[0]
22+
// 默认降序 1:End < 0:Start
23+
if v, ok := than.(indexItem); ok {
24+
return i[1] < v[0]
25+
26+
}
27+
return i[1] < than.(indexItemAscend)[0]
28+
}
29+
30+
// indexItem 升序
31+
type indexItemAscend [4]uint32
32+
33+
func (i indexItemAscend) Less(than btree.Item) bool {
34+
// 升序 0:End < 0:Start
35+
if v, ok := than.(indexItem); ok {
36+
return i[0] < v[0]
37+
38+
}
39+
return i[0] < than.(indexItemAscend)[0]
2440
}
2541

2642
type indexes struct {
@@ -37,7 +53,7 @@ func (idx *indexes) indexOf(u uint32) (hit indexItem) {
3753
return false
3854
})
3955
} else if u < idx.indexMid[0] {
40-
idx.index.AscendGreaterOrEqual(indexItem{u}, func(i btree.Item) bool {
56+
idx.index.AscendGreaterOrEqual(indexItemAscend{u}, func(i btree.Item) bool {
4157
hit = i.(indexItem)
4258
return false
4359
})

0 commit comments

Comments
 (0)