You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
It occurs to me that it would probably be useful to have a Peek method in the heap package that returns the highest priority item without removing it from the heap. That is to say I'd definitely find it useful. The potential problem lies in that I believe that this would require a change to heap.Interface, which will potentially break a lot of code if changed.
If people still think its worthwhile, I'd be happy to submit a CL.
graham
roger peppe
unread,
Dec 9, 2010, 1:56:54 PM12/9/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Graham Miller, golang-nuts
the highest priority item is at index zero. this could be better documented.
gmiller
unread,
Dec 9, 2010, 2:32:25 PM12/9/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
If all you have is a reference to a heap.Interface, there is no
concept of a zeroth element, only Push, Pop, Init and Remove.
graham
On Dec 9, 1:56 pm, roger peppe <rogpe...@gmail.com> wrote:
> the highest priority item is at index zero.
> this could be better documented.
>
Russ Cox
unread,
Dec 9, 2010, 3:21:59 PM12/9/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gmiller, golang-nuts
Instead of changing the package, in your specific code using the heap you can just use h[0], since your code (in contrast to the heap code) knows the layout of the underlying type.
Russ
roger peppe
unread,
Dec 10, 2010, 4:48:05 AM12/10/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gmiller, golang-nuts
On 9 December 2010 19:32, gmiller <graham...@gmail.com> wrote: > If all you have is a reference to a heap.Interface, there is no > concept of a zeroth element, only Push, Pop, Init and Remove.
what russ says, but to be pedantic, you've got Len, Less and Swap too :-)