Binary min-heap aligned with `container/heap` Init/Push/Pop, specialized to `IntHeap` / `StrHeap` (no Interface / function values). Logical length `n` is separate from backing capacity so Pop is O(log n) and does not rebuild the array. Mutating API is methods (field `.push` on `&mut Struct` params does not write the descriptor back).
Parameters
a[]int
field ([]int)
nint
count, length, or limit
struct StrHeap
XuAPI
pubstruct StrHeap {
pub a []stringpub n int
}
Purpose
Public struct `StrHeap`.
Parameters
a[]string
field ([]string)
nint
count, length, or limit
new_ints
XuAPI
pubfn new_ints() IntHeap
Purpose
Construct ints.
Parameters
none
Returns
IntHeap — a value of this type
new_strs
XuAPI
pubfn new_strs() StrHeap
Purpose
Construct strs.
Parameters
none
Returns
StrHeap — a value of this type
from_ints
XuAPI
pubfn from_ints(xs []int) IntHeap
Purpose
Build from ints.
Parameters
xs[]int
slice to operate on ([]int)
Returns
IntHeap — a value of this type
from_strs
XuAPI
pubfn from_strs(xs []string) StrHeap
Purpose
Build from strs.
Parameters
xs[]string
slice to operate on ([]string)
Returns
StrHeap — a value of this type
len_ints
XuAPI
pubfn len_ints(h &IntHeap) int
Purpose
Len int slice.
Parameters
h&IntHeap
height or handle (borrowed; caller keeps it; type &IntHeap)
Returns
int — a value of this type
len_strs
XuAPI
pubfn len_strs(h &StrHeap) int
Purpose
Len strs.
Parameters
h&StrHeap
height or handle (borrowed; caller keeps it; type &StrHeap)