diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-03-02 20:01:37 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-03-02 20:01:37 +0000 |
commit | 501699af1603287b1b47ac450fd6eeb826aa76b1 (patch) | |
tree | 3eeb8918d39d675108073c8b76d6dd10586a608c /libgo/go/container | |
parent | 34c5f21a387dc461042bafc3052ce6e1af786a77 (diff) | |
download | gcc-501699af1603287b1b47ac450fd6eeb826aa76b1.tar.gz |
libgo: Update to weekly.2012-02-22 release.
From-SVN: r184819
Diffstat (limited to 'libgo/go/container')
-rw-r--r-- | libgo/go/container/heap/example_test.go | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/libgo/go/container/heap/example_test.go b/libgo/go/container/heap/example_test.go index c3b8d94cb2a..2050bc83591 100644 --- a/libgo/go/container/heap/example_test.go +++ b/libgo/go/container/heap/example_test.go @@ -57,11 +57,26 @@ func (pq *PriorityQueue) Pop() interface{} { return item } -// 99:seven 88:five 77:zero 66:nine 55:three 44:two 33:six 22:one 11:four 00:eight -func ExampleInterface() { - // The full code of this example, including the methods that implement - // heap.Interface, is in the file src/pkg/container/heap/example_test.go. +// update is not used by the example but shows how to take the top item from +// the queue, update its priority and value, and put it back. +func (pq *PriorityQueue) update(value string, priority int) { + item := heap.Pop(pq).(*Item) + item.value = value + item.priority = priority + heap.Push(pq, item) +} +// changePriority is not used by the example but shows how to change the +// priority of an arbitrary item. +func (pq *PriorityQueue) changePriority(item *Item, priority int) { + heap.Remove(pq, item.index) + item.priority = priority + heap.Push(pq, item) +} + +// This example pushes 10 items into a PriorityQueue and takes them out in +// order of priority. +func Example() { const nItem = 10 // Random priorities for the items (a permutation of 0..9, times 11)). priorities := [nItem]int{ @@ -85,21 +100,6 @@ func ExampleInterface() { item := heap.Pop(&pq).(*Item) fmt.Printf("%.2d:%s ", item.priority, item.value) } -} - -// update is not used by the example but shows how to take the top item from the queue, -// update its priority and value, and put it back. -func (pq *PriorityQueue) update(value string, priority int) { - item := heap.Pop(pq).(*Item) - item.value = value - item.priority = priority - heap.Push(pq, item) -} - -// changePriority is not used by the example but shows how to change the priority of an arbitrary -// item. -func (pq *PriorityQueue) changePriority(item *Item, priority int) { - heap.Remove(pq, item.index) - item.priority = priority - heap.Push(pq, item) + // Output: + // 99:seven 88:five 77:zero 66:nine 55:three 44:two 33:six 22:one 11:four 00:eight } |