Documentation ¶
Index ¶
- type MaxHeap
- func (mh *MaxHeap[T]) Add(element T)
- func (mh *MaxHeap[T]) Clear()
- func (mh *MaxHeap[T]) GetLeftChildIndex(parent int) int
- func (mh *MaxHeap[T]) GetParentIndex(child int) int
- func (mh *MaxHeap[T]) GetRightChildIndex(parent int) int
- func (mh *MaxHeap[T]) HasLeftChild(parent int) bool
- func (mh *MaxHeap[T]) HasParent(child int) bool
- func (mh *MaxHeap[T]) HasRightChild(parent int) bool
- func (mh *MaxHeap[T]) IsEmpty() bool
- func (mh *MaxHeap[T]) LeftChild(parent int) T
- func (mh *MaxHeap[T]) Parent(child int) T
- func (mh *MaxHeap[T]) Peek() (T, error)
- func (mh *MaxHeap[T]) Poll() (T, error)
- func (mh *MaxHeap[T]) RightChild(parent int) T
- func (mh *MaxHeap[T]) Size() int
- func (mh *MaxHeap[T]) String() string
- func (mh *MaxHeap[T]) Values() []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MaxHeap ¶
type MaxHeap[T constraints.Ordered] struct { // contains filtered or unexported fields }
Array implementation of heap
func New ¶
func New[T constraints.Ordered](values ...T) *MaxHeap[T]
Returns a new MinHeap implementation
func (*MaxHeap[T]) GetLeftChildIndex ¶
Get the left child index of a given node
func (*MaxHeap[T]) GetParentIndex ¶
Get the parent index of a node
func (*MaxHeap[T]) GetRightChildIndex ¶
Get the right child index of a given node
func (*MaxHeap[T]) HasLeftChild ¶
Check if the current node has a left child
func (*MaxHeap[T]) HasRightChild ¶
Check if current node has a right child
func (*MaxHeap[T]) RightChild ¶
Get the right child of the given node
Click to show internal directories.
Click to hide internal directories.