You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var unconfirmedMap *treemap.TreeMap[decimal.Decimal, *wm_model.Block] = treemap.NewWithKeyCompare[ decimal.Decimal, *wm_model.Block ] (BlockNumberCmp)
func BlockNumberCmp(left decimal.Decimal, right decimal.Decimal) bool {
return left.Cmp(right) < 0
}
func DoSomething(latestFastConfirmNum decimal.Decimal) []*wm_model.Block{
var movedBlockList []*wm_model.Block = make([]*wm_model.Block, 0)
it := unconfirmedMap.UpperBound(latestFastConfirmNum)
if it.Valid() {
for it.Prev(); it.Valid(); it.Prev() {
movedBlockList = append(movedBlockList, it.Value())
}
for _, item := range movedBlockList {
unconfirmedMap.Del(item.BlockNumber)
}
}
return movedBlockList
}
Panic at it.Prev()
Besides, I would suggest Valid() function would also check if it is before the first element
If the forward iterator just expect to work forward only, I would suggest a function to convert a forward iterator to a reverse iterator
The text was updated successfully, but these errors were encountered:
Panic at it.Prev()
Besides, I would suggest Valid() function would also check if it is before the first element
If the forward iterator just expect to work forward only, I would suggest a function to convert a forward iterator to a reverse iterator
The text was updated successfully, but these errors were encountered: