diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-03-03 22:13:29 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-03-03 22:13:29 +0000 |
commit | 5f5127ba9ddb8f52d43827b6ab96b8169af5075f (patch) | |
tree | 701124de37c5bf475ba6920641948d637da0ee8b /pkg/ilist/interface_list.go | |
parent | 56f91c540e938374a025c31cf23aa2e4d00cacec (diff) | |
parent | 844e4d284cddf9795a0db7c38f926fe7b49bb873 (diff) |
Merge release-20200219.0-91-g844e4d2 (automated)
Diffstat (limited to 'pkg/ilist/interface_list.go')
-rwxr-xr-x | pkg/ilist/interface_list.go | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/pkg/ilist/interface_list.go b/pkg/ilist/interface_list.go index 940c2d3f6..a69f736c6 100755 --- a/pkg/ilist/interface_list.go +++ b/pkg/ilist/interface_list.go @@ -73,8 +73,9 @@ func (l *List) Back() Element { // PushFront inserts the element e at the front of list l. func (l *List) PushFront(e Element) { - ElementMapper{}.linkerFor(e).SetNext(l.head) - ElementMapper{}.linkerFor(e).SetPrev(nil) + linker := ElementMapper{}.linkerFor(e) + linker.SetNext(l.head) + linker.SetPrev(nil) if l.head != nil { ElementMapper{}.linkerFor(l.head).SetPrev(e) @@ -87,8 +88,9 @@ func (l *List) PushFront(e Element) { // PushBack inserts the element e at the back of list l. func (l *List) PushBack(e Element) { - ElementMapper{}.linkerFor(e).SetNext(nil) - ElementMapper{}.linkerFor(e).SetPrev(l.tail) + linker := ElementMapper{}.linkerFor(e) + linker.SetNext(nil) + linker.SetPrev(l.tail) if l.tail != nil { ElementMapper{}.linkerFor(l.tail).SetNext(e) @@ -117,10 +119,14 @@ func (l *List) PushBackList(m *List) { // InsertAfter inserts e after b. func (l *List) InsertAfter(b, e Element) { - a := ElementMapper{}.linkerFor(b).Next() - ElementMapper{}.linkerFor(e).SetNext(a) - ElementMapper{}.linkerFor(e).SetPrev(b) - ElementMapper{}.linkerFor(b).SetNext(e) + bLinker := ElementMapper{}.linkerFor(b) + eLinker := ElementMapper{}.linkerFor(e) + + a := bLinker.Next() + + eLinker.SetNext(a) + eLinker.SetPrev(b) + bLinker.SetNext(e) if a != nil { ElementMapper{}.linkerFor(a).SetPrev(e) @@ -131,10 +137,13 @@ func (l *List) InsertAfter(b, e Element) { // InsertBefore inserts e before a. func (l *List) InsertBefore(a, e Element) { - b := ElementMapper{}.linkerFor(a).Prev() - ElementMapper{}.linkerFor(e).SetNext(a) - ElementMapper{}.linkerFor(e).SetPrev(b) - ElementMapper{}.linkerFor(a).SetPrev(e) + aLinker := ElementMapper{}.linkerFor(a) + eLinker := ElementMapper{}.linkerFor(e) + + b := aLinker.Prev() + eLinker.SetNext(a) + eLinker.SetPrev(b) + aLinker.SetPrev(e) if b != nil { ElementMapper{}.linkerFor(b).SetNext(e) |