diff options
Diffstat (limited to 'src/pkg/container/list/list.go')
-rw-r--r-- | src/pkg/container/list/list.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/pkg/container/list/list.go b/src/pkg/container/list/list.go index ed2d15a45..0256768ef 100644 --- a/src/pkg/container/list/list.go +++ b/src/pkg/container/list/list.go @@ -65,7 +65,7 @@ func New() *List { return new(List).Init() } // The complexity is O(1). func (l *List) Len() int { return l.len } -// Front returns the first element of list l or nil +// Front returns the first element of list l or nil. func (l *List) Front() *Element { if l.len == 0 { return nil @@ -180,18 +180,18 @@ func (l *List) MoveToBack(e *Element) { } // MoveBefore moves element e to its new position before mark. -// If e is not an element of l, or e == mark, the list is not modified. +// If e or mark is not an element of l, or e == mark, the list is not modified. func (l *List) MoveBefore(e, mark *Element) { - if e.list != l || e == mark { + if e.list != l || e == mark || mark.list != l { return } l.insert(l.remove(e), mark.prev) } // MoveAfter moves element e to its new position after mark. -// If e is not an element of l, or e == mark, the list is not modified. +// If e or mark is not an element of l, or e == mark, the list is not modified. func (l *List) MoveAfter(e, mark *Element) { - if e.list != l || e == mark { + if e.list != l || e == mark || mark.list != l { return } l.insert(l.remove(e), mark) |