Discover Packages
github.com/stellar/go
support
collections
heap
package
Version:
v0.0.0-...-089553b
Opens a new window with list of versions in this module.
Published: Dec 20, 2024
License: Apache-2.0, Apache-2.0
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 2
Opens a new window with list of known importers.
Documentation
Documentation
¶
type Heap[E any ] struct {
}
A Heap is a min-heap backed by a slice.
New constructs a new Heap with a comparison function.
Len returns the number of elements in the heap.
func (h *Heap [E]) Peek() E
Peek returns the minimum element (according to the less function) in the heap.
Peek panics if the heap is empty.
The complexity is O(1).
func (h *Heap [E]) Pop() E
Pop removes and returns the minimum element (according to the less function)
from the heap. Pop panics if the heap is empty.
The complexity is O(log n) where n = h.Len().
func (h *Heap [E]) Push(elem E)
Push pushes an element onto the heap. The complexity is O(log n)
where n = h.Len().
Source Files
¶
Click to show internal directories.
Click to hide internal directories.