diff options
author | Ian Lance Taylor <iant@golang.org> | 2019-01-18 19:04:36 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-01-18 19:04:36 +0000 |
commit | 4f4a855d82a889cebcfca150a7a43909bcb6a346 (patch) | |
tree | f12bae0781920fa34669fe30b6f4615a86d9fb80 /libgo/go/container | |
parent | 225220d668dafb8262db7012bced688acbe63b33 (diff) |
libgo: update to Go1.12beta2
Reviewed-on: https://go-review.googlesource.com/c/158019
gotools/:
* Makefile.am (go_cmd_vet_files): Update for Go1.12beta2 release.
(GOTOOLS_TEST_TIMEOUT): Increase to 600.
(check-runtime): Export LD_LIBRARY_PATH before computing GOARCH
and GOOS.
(check-vet): Copy golang.org/x/tools into check-vet-dir.
* Makefile.in: Regenerate.
gcc/testsuite/:
* go.go-torture/execute/names-1.go: Stop using debug/xcoff, which
is no longer externally visible.
From-SVN: r268084
Diffstat (limited to 'libgo/go/container')
-rw-r--r-- | libgo/go/container/heap/heap.go | 21 | ||||
-rw-r--r-- | libgo/go/container/list/list.go | 25 |
2 files changed, 30 insertions, 16 deletions
diff --git a/libgo/go/container/heap/heap.go b/libgo/go/container/heap/heap.go index 67b5efcac7e..2e09da8613a 100644 --- a/libgo/go/container/heap/heap.go +++ b/libgo/go/container/heap/heap.go @@ -38,7 +38,7 @@ type Interface interface { // Init establishes the heap invariants required by the other routines in this package. // Init is idempotent with respect to the heap invariants // and may be called whenever the heap invariants may have been invalidated. -// Its complexity is O(n) where n = h.Len(). +// The complexity is O(n) where n = h.Len(). func Init(h Interface) { // heapify n := h.Len() @@ -47,18 +47,16 @@ func Init(h Interface) { } } -// Push pushes the element x onto the heap. The complexity is -// O(log(n)) where n = h.Len(). -// +// Push pushes the element x onto the heap. +// The complexity is O(log n) where n = h.Len(). func Push(h Interface, x interface{}) { h.Push(x) up(h, h.Len()-1) } -// Pop removes the minimum element (according to Less) from the heap -// and returns it. The complexity is O(log(n)) where n = h.Len(). -// It is equivalent to Remove(h, 0). -// +// Pop removes and returns the minimum element (according to Less) from the heap. +// The complexity is O(log n) where n = h.Len(). +// Pop is equivalent to Remove(h, 0). func Pop(h Interface) interface{} { n := h.Len() - 1 h.Swap(0, n) @@ -66,9 +64,8 @@ func Pop(h Interface) interface{} { return h.Pop() } -// Remove removes the element at index i from the heap. -// The complexity is O(log(n)) where n = h.Len(). -// +// Remove removes and returns the element at index i from the heap. +// The complexity is O(log n) where n = h.Len(). func Remove(h Interface, i int) interface{} { n := h.Len() - 1 if n != i { @@ -83,7 +80,7 @@ func Remove(h Interface, i int) interface{} { // Fix re-establishes the heap ordering after the element at index i has changed its value. // Changing the value of the element at index i and then calling Fix is equivalent to, // but less expensive than, calling Remove(h, i) followed by a Push of the new value. -// The complexity is O(log(n)) where n = h.Len(). +// The complexity is O(log n) where n = h.Len(). func Fix(h Interface, i int) { if !down(h, i, h.Len()) { up(h, i) diff --git a/libgo/go/container/list/list.go b/libgo/go/container/list/list.go index dc4260e1316..b8b599aabb1 100644 --- a/libgo/go/container/list/list.go +++ b/libgo/go/container/list/list.go @@ -116,6 +116,23 @@ func (l *List) remove(e *Element) *Element { return e } +// move moves e to next to at and returns e. +func (l *List) move(e, at *Element) *Element { + if e == at { + return e + } + e.prev.next = e.next + e.next.prev = e.prev + + n := at.next + at.next = e + e.prev = at + e.next = n + n.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. @@ -170,7 +187,7 @@ func (l *List) MoveToFront(e *Element) { return } // see comment in List.Remove about initialization of l - l.insert(l.remove(e), &l.root) + l.move(e, &l.root) } // MoveToBack moves element e to the back of list l. @@ -181,7 +198,7 @@ func (l *List) MoveToBack(e *Element) { return } // see comment in List.Remove about initialization of l - l.insert(l.remove(e), l.root.prev) + l.move(e, l.root.prev) } // MoveBefore moves element e to its new position before mark. @@ -191,7 +208,7 @@ func (l *List) MoveBefore(e, mark *Element) { if e.list != l || e == mark || mark.list != l { return } - l.insert(l.remove(e), mark.prev) + l.move(e, mark.prev) } // MoveAfter moves element e to its new position after mark. @@ -201,7 +218,7 @@ func (l *List) MoveAfter(e, mark *Element) { if e.list != l || e == mark || mark.list != l { return } - l.insert(l.remove(e), mark) + l.move(e, mark) } // PushBackList inserts a copy of an other list at the back of list l. |