Skip to content

Instantly share code, notes, and snippets.

working on it...

josh bowles jbowles

working on it...
View GitHub Profile
Komosa / gheap.go
Last active Nov 7, 2015
Golang doesn't need neither runtime type-assertion nor code generation to provide generics
View gheap.go
// this package is mostly copy-pasted from golang's std container/heap
// I changed Interface, Pop and Push in order to get rid of type assertions
// usage can be found in test file, benchmarks show that we can get about 27% of speedup for 1000 elems, or 10% for 10M elems (tested on go1.4)
package gheap
type Interface interface {
Len() int
Less(i, j int) bool
Swap(i, j int)