Documentation ¶
Index ¶
- type BinaryHeap
- func (heap *BinaryHeap[T]) Clear()
- func (heap *BinaryHeap[T]) Fix(i int, k T)
- func (heap *BinaryHeap[T]) Iterator() containers.IndexIterator[T]
- func (heap *BinaryHeap[T]) Merge(h Heap[T])
- func (heap *BinaryHeap[T]) Peek() (_ T, _ bool)
- func (heap *BinaryHeap[T]) Pop() (_ T, _ bool)
- func (heap *BinaryHeap[T]) Push(es ...T)
- func (heap *BinaryHeap[T]) Remove(i int)
- func (heap *BinaryHeap[T]) Size() int
- func (heap *BinaryHeap[T]) String() string
- func (heap *BinaryHeap[T]) Values() []T
- type Heap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinaryHeap ¶
type BinaryHeap[T any] struct { // contains filtered or unexported fields }
func NewBinaryHeap ¶
func NewBinaryHeap[T any](capacity int, compare containers.Compare[T]) *BinaryHeap[T]
func (*BinaryHeap[T]) Clear ¶
func (heap *BinaryHeap[T]) Clear()
func (*BinaryHeap[T]) Fix ¶
func (heap *BinaryHeap[T]) Fix(i int, k T)
func (*BinaryHeap[T]) Iterator ¶
func (heap *BinaryHeap[T]) Iterator() containers.IndexIterator[T]
func (*BinaryHeap[T]) Merge ¶
func (heap *BinaryHeap[T]) Merge(h Heap[T])
func (*BinaryHeap[T]) Peek ¶
func (heap *BinaryHeap[T]) Peek() (_ T, _ bool)
func (*BinaryHeap[T]) Pop ¶
func (heap *BinaryHeap[T]) Pop() (_ T, _ bool)
func (*BinaryHeap[T]) Push ¶
func (heap *BinaryHeap[T]) Push(es ...T)
func (*BinaryHeap[T]) Remove ¶
func (heap *BinaryHeap[T]) Remove(i int)
func (*BinaryHeap[T]) Size ¶
func (heap *BinaryHeap[T]) Size() int
func (*BinaryHeap[T]) String ¶
func (heap *BinaryHeap[T]) String() string
func (*BinaryHeap[T]) Values ¶
func (heap *BinaryHeap[T]) Values() []T
type Heap ¶
type Heap[T any] interface { // Push pushes an element into queue Push(e ...T) // Peek returns an element on the head of queue Peek() (T, bool) // Pop returns an element on the head of queue, then pop it from queue Pop() (T, bool) // Fix replace the element at the given index to k, returns if k equal to the element or re-heapify Fix(i int, k T) // Remove removes an element at the give index from heap Remove(i int) // Merge merges another heap into this one Merge(heap Heap[T]) containers.IndexIterable[T] containers.Container[T] }
Heap is the base interface of all heap implementations
Click to show internal directories.
Click to hide internal directories.