Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion heap/heap.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package heap

import (
"slices"

g "github.com/zyedidia/generic"
)

Expand All @@ -23,7 +25,7 @@ func New[T any](less g.LessFn[T]) *Heap[T] {

// From returns a new heap with the given less function and initial data.
func From[T any](less g.LessFn[T], t ...T) *Heap[T] {
return FromSlice(less, t)
return FromSlice(less, slices.Clone(t))
}

// FromSlice returns a new heap with the given less function and initial data.
Expand Down