Golang的Heap使用之谜
Go语言的官方package里面提供了"container/heap",在该package里面定义了Heap(堆)这一数据结构的使用接口。只要自定义的数据类型实现了标准接口,可以很方便的对自定义的数据类型在堆中进行排序了。 堆结构的接口为: type Interface interface { sort.Interface Push(x interface{}) // add x as element Len() Pop() interface{} // remove and return element Len() - 1. } 同时sort.Interface接口为: type Interface interface { // Len is the number of elements ...阅读全文