Documentation
¶
Index ¶
- type Heap
- type MaxHeap
- func CreateMaxHeap(comparator func(thisValue interface{}, compareValue interface{}) int, ...) MaxHeap
- func CreateMaxHeapDefault(comparator func(thisValue interface{}, compareValue interface{}) int) MaxHeap
- func CreateMaxHeapFromSliceArray(comparator func(thisValue interface{}, compareValue interface{}) int, ...) MaxHeap
- type MinHeap
- func CreateMinHeap(comparator func(thisValue interface{}, compareValue interface{}) int, ...) MinHeap
- func CreateMinHeapDefault(comparator func(thisValue interface{}, compareValue interface{}) int) MinHeap
- func CreateMinHeapFromSliceArray(comparator func(thisValue interface{}, compareValue interface{}) int, ...) MinHeap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MaxHeap ¶
type MaxHeap struct {
// contains filtered or unexported fields
}
最大堆 堆是一棵完全二叉树
func CreateMaxHeap ¶
func CreateMaxHeap(comparator func(thisValue interface{}, compareValue interface{}) int, capacity int) MaxHeap
创建一个指定容量的最大堆
func CreateMaxHeapDefault ¶
func CreateMaxHeapDefault(comparator func(thisValue interface{}, compareValue interface{}) int) MaxHeap
创建一个默认容量的最大堆
func CreateMaxHeapFromSliceArray ¶
func CreateMaxHeapFromSliceArray(comparator func(thisValue interface{}, compareValue interface{}) int, sourceSlice array.SliceArray) MaxHeap
O(n) 根据slice创建最大堆 使用heapify的方式将slice转换为最大堆
func (MaxHeap) ExtractTop ¶
O(log(n)) 提取出最大的元素
type MinHeap ¶
type MinHeap struct {
// contains filtered or unexported fields
}
func CreateMinHeap ¶
func CreateMinHeap(comparator func(thisValue interface{}, compareValue interface{}) int, capacity int) MinHeap
创建一个指定容量的最小堆
func CreateMinHeapDefault ¶
func CreateMinHeapDefault(comparator func(thisValue interface{}, compareValue interface{}) int) MinHeap
创建一个默认容量的最小堆
func CreateMinHeapFromSliceArray ¶
func CreateMinHeapFromSliceArray(comparator func(thisValue interface{}, compareValue interface{}) int, sourceSlice array.SliceArray) MinHeap
O(n) 使用heapify的方式将slice转换为最小堆
func (MinHeap) ExtractTop ¶
Click to show internal directories.
Click to hide internal directories.