mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-12 16:52:29 +08:00
refactor: BuildMaxHeap
This commit is contained in:
@@ -28,7 +28,7 @@ func NewMaxHeap[T any](comparator lancetconstraints.Comparator) *MaxHeap[T] {
|
|||||||
// BuildMaxHeap builds a MaxHeap instance with data and given comparator.
|
// BuildMaxHeap builds a MaxHeap instance with data and given comparator.
|
||||||
func BuildMaxHeap[T any](data []T, comparator lancetconstraints.Comparator) *MaxHeap[T] {
|
func BuildMaxHeap[T any](data []T, comparator lancetconstraints.Comparator) *MaxHeap[T] {
|
||||||
heap := &MaxHeap[T]{
|
heap := &MaxHeap[T]{
|
||||||
data: make([]T, 0),
|
data: make([]T, 0, len(data)),
|
||||||
comparator: comparator,
|
comparator: comparator,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user