TODO: list insert error
This commit is contained in:
parent
539e764c08
commit
19a4034928
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user