Her*_*rks 7 interface go
我不明白container/heap包中的以下代码片段.
container/heap
type Interface interface { sort.Interface //Is this line a method? Push(x interface{}) Pop() interface{} }
Den*_*ret 7
这是一种类型声明.
该heap.Interface接口嵌入sort.Interface接口.
heap.Interface
sort.Interface
您可以将其视为一种继承/特化:它意味着实现heap.Interface接口的结构被定义为实现sort.Interface方法Push和Pop方法的结构.
Push
Pop
接口嵌入在Effective Go中有描述:http://golang.org/doc/effective_go.html#embedding
归档时间:
13 年,7 月 前
查看次数:
127 次
最近记录:
11 年,2 月 前