clipperhouse / gen

Type-driven code generation for Go
http://clipperhouse.com/gen/overview/
Other
1.43k stars 90 forks source link

Heap interface (for priority queues) #110

Open aseemk opened 6 years ago

aseemk commented 6 years ago

Hey there,

Great work again. =) Just wanted to say it'd be sweet if the slice typewriter could support codegen'ing a PriorityQueue implementation too, via the Heap interface:

https://golang.org/pkg/container/heap/ (see PriorityQueue example)

Although if it's helpful, what I'm really looking to do is something like a "top N by \<func>". An ideal implementation would use a heap/priority queue with capacity N, so discard anything ranked lower than N as I iterate over the slice and add things to this heap/priority queue.

Thanks for the consideration!