2019-04-11 13:34:50 +00:00
|
|
|
package heap
|
|
|
|
|
|
|
|
import (
|
|
|
|
"474420502.top/eson/structure/compare"
|
2019-04-14 17:42:22 +00:00
|
|
|
"474420502.top/eson/structure/sparse_array/array3"
|
2019-04-11 13:34:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Heap struct {
|
|
|
|
size int
|
|
|
|
cap int
|
2019-04-14 17:42:22 +00:00
|
|
|
elements *array3.Array3
|
2019-04-11 13:34:50 +00:00
|
|
|
Compare compare.Compare
|
|
|
|
}
|
|
|
|
|
|
|
|
func New(Compare compare.Compare) *Heap {
|
2019-04-14 17:42:22 +00:00
|
|
|
h := &Heap{Compare: Compare, cap: 8}
|
|
|
|
h.elements = array3.NewWithCap(4, 4, 4)
|
|
|
|
return h
|
2019-04-11 13:34:50 +00:00
|
|
|
}
|