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