From 19a403492895b79f54c7fdc5486b942fee2fa65d Mon Sep 17 00:00:00 2001 From: huangsimin Date: Thu, 20 Dec 2018 18:46:41 +0800 Subject: [PATCH] TODO: list insert error --- priority_list.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/priority_list.go b/priority_list.go index e4580c8..1310451 100644 --- a/priority_list.go +++ b/priority_list.go @@ -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) } }