diff options
Diffstat (limited to 'libgo/go/container/list/list.go')
-rw-r--r-- | libgo/go/container/list/list.go | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/libgo/go/container/list/list.go b/libgo/go/container/list/list.go index 210424ceed7..9555ad39003 100644 --- a/libgo/go/container/list/list.go +++ b/libgo/go/container/list/list.go @@ -24,7 +24,7 @@ type Element struct { list *List // The value stored with this element. - Value interface{} + Value any } // Next returns the next list element or nil. @@ -100,25 +100,24 @@ func (l *List) insert(e, at *Element) *Element { } // insertValue is a convenience wrapper for insert(&Element{Value: v}, at). -func (l *List) insertValue(v interface{}, at *Element) *Element { +func (l *List) insertValue(v any, at *Element) *Element { return l.insert(&Element{Value: v}, at) } -// remove removes e from its list, decrements l.len, and returns e. -func (l *List) remove(e *Element) *Element { +// remove removes e from its list, decrements l.len +func (l *List) remove(e *Element) { e.prev.next = e.next e.next.prev = e.prev e.next = nil // avoid memory leaks e.prev = nil // avoid memory leaks e.list = nil l.len-- - return e } -// move moves e to next to at and returns e. -func (l *List) move(e, at *Element) *Element { +// move moves e to next to at. +func (l *List) move(e, at *Element) { if e == at { - return e + return } e.prev.next = e.next e.next.prev = e.prev @@ -127,14 +126,12 @@ func (l *List) move(e, at *Element) *Element { e.next = at.next e.prev.next = e e.next.prev = e - - return e } // Remove removes e from l if e is an element of list l. // It returns the element value e.Value. // The element must not be nil. -func (l *List) Remove(e *Element) interface{} { +func (l *List) Remove(e *Element) any { if e.list == l { // if e.list == l, l must have been initialized when e was inserted // in l or l == nil (e is a zero Element) and l.remove will crash @@ -144,13 +141,13 @@ func (l *List) Remove(e *Element) interface{} { } // PushFront inserts a new element e with value v at the front of list l and returns e. -func (l *List) PushFront(v interface{}) *Element { +func (l *List) PushFront(v any) *Element { l.lazyInit() return l.insertValue(v, &l.root) } // PushBack inserts a new element e with value v at the back of list l and returns e. -func (l *List) PushBack(v interface{}) *Element { +func (l *List) PushBack(v any) *Element { l.lazyInit() return l.insertValue(v, l.root.prev) } @@ -158,7 +155,7 @@ func (l *List) PushBack(v interface{}) *Element { // InsertBefore inserts a new element e with value v immediately before mark and returns e. // If mark is not an element of l, the list is not modified. // The mark must not be nil. -func (l *List) InsertBefore(v interface{}, mark *Element) *Element { +func (l *List) InsertBefore(v any, mark *Element) *Element { if mark.list != l { return nil } @@ -169,7 +166,7 @@ func (l *List) InsertBefore(v interface{}, mark *Element) *Element { // InsertAfter inserts a new element e with value v immediately after mark and returns e. // If mark is not an element of l, the list is not modified. // The mark must not be nil. -func (l *List) InsertAfter(v interface{}, mark *Element) *Element { +func (l *List) InsertAfter(v any, mark *Element) *Element { if mark.list != l { return nil } |