Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HeapNode ¶
type HeapNode interface {
Value() int
}
HeapNode is an interface making the type for a Min/MaxHeap node flexible nodes must be be able to state their value to be sorted by
type MaxHeap ¶
type MaxHeap struct {
// contains filtered or unexported fields
}
MaxHeap is an implementation of max heap
func NewMaxHeap ¶
func NewMaxHeap() *MaxHeap
NewMaxHeap initializes a heap with a closerToRootFunction that simply returns true if the first arg is larger than the second
func (*MaxHeap) Add ¶
func (h *MaxHeap) Add(newNode HeapNode)
Add appends a new node onto the heap and heapifies it to ensure correct ordering
type MinHeap ¶
type MinHeap struct {
// contains filtered or unexported fields
}
MinHeap is an implementation of a min heap
func NewMinHeap ¶
func NewMinHeap() *MinHeap
NewMinHeap initializes a heap with a closerToRootFunction that simply returns true if the first arg is smaller than the second
func (*MinHeap) Add ¶
func (h *MinHeap) Add(newNode HeapNode)
Add appends a new node onto the heap and heapifies it to ensure correct ordering