This commit is contained in:
aozhiwei 2023-09-15 07:35:10 +08:00
parent 37aba94237
commit a784d12ab4

View File

@ -47,6 +47,9 @@ func (this *ListHead) AddHead(pnew *ListHead) {
} }
func (this *ListHead) FirstEntry() interface{} { func (this *ListHead) FirstEntry() interface{} {
if this.next.data != dummyData {
return this.next.data
}
for pos := this.next; pos != this; pos = pos.next { for pos := this.next; pos != this; pos = pos.next {
if pos.data != dummyData { if pos.data != dummyData {
return pos.data return pos.data
@ -110,17 +113,18 @@ func (this *ListHead) ForEach(cb ListHead_Foreach_Func) {
break break
} }
if cursor.next == oldN { if cursor.next == oldN {
cursor.next = oldN.next oldN.Del()
oldN.next.prev = &cursor
oldN.prev = cursor.prev
cursor.prev.next = oldN
oldN.next = &cursor oldN.next = &cursor
cursor.prev = oldN oldN.next.prev = oldN
oldN.prev = cursor.prev
oldN.prev.next = oldN
} }
} }
} }
func NewListHead () *ListHead{ func NewListHead () *ListHead {
l := new(ListHead) l := new(ListHead)
l.Init(nil) l.Init(nil)
return l return l