Documentation ¶
Index ¶
- Constants
- type Element
- type Heap
- func (c *Heap[T]) Clone() *Heap[T]
- func (c *Heap[T]) Len() int
- func (c *Heap[T]) Pop() (ele T)
- func (c *Heap[T]) Push(v T)
- func (c *Heap[T]) Range(f func(index int, value T) bool)
- func (c *Heap[T]) Reset()
- func (c *Heap[T]) SetCap(n int) *Heap[T]
- func (c *Heap[T]) Top() T
- func (c *Heap[T]) UnWrap() []T
- type IndexedHeap
- func (c *IndexedHeap[K, V]) Clone() *IndexedHeap[K, V]
- func (c *IndexedHeap[K, V]) DeleteByIndex(index int)
- func (c *IndexedHeap[K, V]) GetByIndex(index int) *Element[K, V]
- func (c *IndexedHeap[K, V]) Len() int
- func (c *IndexedHeap[K, V]) Pop() (ele *Element[K, V])
- func (c *IndexedHeap[K, V]) Push(key K, value V) *Element[K, V]
- func (c *IndexedHeap[K, V]) Range(f func(ele *Element[K, V]) bool)
- func (c *IndexedHeap[K, V]) Reset()
- func (c *IndexedHeap[K, V]) SetCap(n int) *IndexedHeap[K, V]
- func (c *IndexedHeap[K, V]) Top() *Element[K, V]
- func (c *IndexedHeap[K, V]) UpdateKeyByIndex(index int, key K)
Constants ¶
View Source
const ( Binary = 2 Quadratic = 4 Octal = 8 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶ added in v1.1.3
type Heap ¶
type Heap[T any] struct { // contains filtered or unexported fields }
func NewWithWays ¶ added in v1.1.3
NewWithWays 新建堆 @ways 分叉数, ways=pow(2,n) @lessFunc 比较函数
type IndexedHeap ¶ added in v1.1.3
func NewIndexedHeap ¶ added in v1.1.3
NewIndexedHeap 新建索引堆 @ways 分叉数, ways=pow(2,n) @lessFunc 比较函数, 可以传空指针, 默认为最小堆
func (*IndexedHeap[K, V]) Clone ¶ added in v1.1.3
func (c *IndexedHeap[K, V]) Clone() *IndexedHeap[K, V]
Clone 拷贝索引堆副本
func (*IndexedHeap[K, V]) DeleteByIndex ¶ added in v1.1.3
func (c *IndexedHeap[K, V]) DeleteByIndex(index int)
DeleteByIndex 通过索引删除元素
func (*IndexedHeap[K, V]) GetByIndex ¶ added in v1.1.3
GetByIndex 通过索引获取元素
func (*IndexedHeap[K, V]) Pop ¶ added in v1.1.3
func (c *IndexedHeap[K, V]) Pop() (ele *Element[K, V])
Pop 弹出堆顶元素
func (*IndexedHeap[K, V]) Push ¶ added in v1.1.3
func (c *IndexedHeap[K, V]) Push(key K, value V) *Element[K, V]
Push 追加元素
func (*IndexedHeap[K, V]) SetCap ¶ added in v1.1.3
func (c *IndexedHeap[K, V]) SetCap(n int) *IndexedHeap[K, V]
SetCap 设置预分配容量
func (*IndexedHeap[K, V]) Top ¶ added in v1.1.3
func (c *IndexedHeap[K, V]) Top() *Element[K, V]
Top 获取堆顶元素
func (*IndexedHeap[K, V]) UpdateKeyByIndex ¶ added in v1.1.3
func (c *IndexedHeap[K, V]) UpdateKeyByIndex(index int, key K)
UpdateKeyByIndex 通过索引更新排序Key
Click to show internal directories.
Click to hide internal directories.