MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / New

Function New

structure/heap/heap.go:15–21  ·  view source on GitHub ↗

New gives a new heap object.

()

Source from the content-addressed store, hash-verified

13
14// New gives a new heap object.
15func New[T constraints.Ordered]() *Heap[T] {
16 less := func(a, b T) bool {
17 return a < b
18 }
19 h, _ := NewAny[T](less)
20 return h
21}
22
23// NewAny gives a new heap object. element can be anything, but must provide less function.
24func NewAny[T any](less func(a, b T) bool) (*Heap[T], error) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected