struct IntHeap
XuAPI
pub struct IntHeap {
pub a []int
pub n int
}用途
承载 a、n 等属性的结构体。
公开字段
a[]int- 字段([]int)
nint- 数量、长度或上限
#container/heapIntHeap / StrHeap 最小堆。
struct IntHeappub struct IntHeap {
pub a []int
pub n int
}承载 a、n 等属性的结构体。
a []intn intstruct StrHeappub struct StrHeap {
pub a []string
pub n int
}承载 a、n 等属性的结构体。
a []stringn intnew_intspub fn new_ints() IntHeap构造 ints。
无需传入参数。
IntHeap — 该类型的值
new_strspub fn new_strs() StrHeap构造 strs。
无需传入参数。
StrHeap — 该类型的值
from_intspub fn from_ints(xs []int) IntHeap从 ints 构造。
xs []intIntHeap — 该类型的值
from_strspub fn from_strs(xs []string) StrHeap从 strs 构造。
xs []stringStrHeap — 该类型的值
len_intspub fn len_ints(h &IntHeap) int长度int 切片。
h &IntHeapint — 该类型的值
len_strspub fn len_strs(h &StrHeap) int执行 len strs 操作。
h &StrHeapint — 该类型的值
($&StrHeap) initpub fn (h $&StrHeap) init()初始化结构体内部状态与默认配置。
h $&StrHeapStrHeap 实例;以独占借用传入,方法可修改它,调用方仍持有实例。不返回值。
($&IntHeap) initpub fn (h $&IntHeap) init()初始化结构体内部状态与默认配置。
h $&IntHeapIntHeap 实例;以独占借用传入,方法可修改它,调用方仍持有实例。不返回值。
($&IntHeap) pushpub fn (h $&IntHeap) push(x int)$&IntHeap 上的操作:压入。
h $&IntHeapIntHeap 实例;以独占借用传入,方法可修改它,调用方仍持有实例。x int不返回值。
($&IntHeap) poppub fn (h $&IntHeap) pop() int$&IntHeap 上的操作:弹出。失败时抛出错误,调用方需处理或继续传播。
h $&IntHeapIntHeap 实例;以独占借用传入,方法可修改它,调用方仍持有实例。int — 该类型的值
($&StrHeap) pushpub fn (h $&StrHeap) push(x string)$&StrHeap 上的操作:压入。
h $&StrHeapStrHeap 实例;以独占借用传入,方法可修改它,调用方仍持有实例。x string不返回值。
($&StrHeap) poppub fn (h $&StrHeap) pop() string$&StrHeap 上的操作:弹出。失败时抛出错误,调用方需处理或继续传播。
h $&StrHeapStrHeap 实例;以独占借用传入,方法可修改它,调用方仍持有实例。string — 结果字符串