NewAny gives a new heap object. element can be anything, but must provide less function.
(less func(a, b T) bool)
| 22 | |
| 23 | // NewAny gives a new heap object. element can be anything, but must provide less function. |
| 24 | func NewAny[T any](less func(a, b T) bool) (*Heap[T], error) { |
| 25 | if less == nil { |
| 26 | return nil, errors.New("less func is necessary") |
| 27 | } |
| 28 | return &Heap[T]{ |
| 29 | lessFunc: less, |
| 30 | }, nil |
| 31 | } |
| 32 | |
| 33 | // Push pushes the element t onto the heap. |
| 34 | // The complexity is O(log n) where n = h.Len(). |
nothing calls this directly
no outgoing calls
no test coverage detected