TODO: list insert error

This commit is contained in:
huangsimin 2018-12-20 18:46:41 +08:00
parent 539e764c08
commit 19a4034928

View File

@ -92,11 +92,11 @@ func (pl *PriorityList) InsertValue(node INode) {
pl.head = node
} else {
cur := pl.head
var prev INode
for cur != nil {
if !cur.Compare(node) {
// 插入该值
prev := cur.GetPrev()
prev = cur.GetPrev()
if prev == nil {
node.SetNext(pl.head)
pl.head = node
@ -105,10 +105,12 @@ func (pl *PriorityList) InsertValue(node INode) {
node.SetNext(cur)
cur.SetPrev(node)
node.SetPrev(prev)
return
}
}
cur = cur.GetNext()
}
prev.SetNext(node)
}
}