XU XUv0.16.0

#container/heap

import: #container/heap

counts: 6 functions, 6 methods, 2 types, 0 constants, 0 method sets

IntHeap / StrHeap min-heaps.

struct IntHeap

XuAPI
pub struct IntHeap {
    pub a []int
    pub n int
}

Purpose

Structure encapsulating a, n.

Public fields

a []int
field ([]int)
n int
count, length, or limit

struct StrHeap

XuAPI
pub struct StrHeap {
    pub a []string
    pub n int
}

Purpose

Structure encapsulating a, n.

Public fields

a []string
field ([]string)
n int
count, length, or limit

new_ints

XuAPI
pub fn new_ints() IntHeap

Purpose

Construct ints.

Parameters

No arguments are required.

Returns

IntHeap — a value of this type

new_strs

XuAPI
pub fn new_strs() StrHeap

Purpose

Construct strs.

Parameters

No arguments are required.

Returns

StrHeap — a value of this type

from_ints

XuAPI
pub fn 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
pub fn 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
pub fn len_ints(h &IntHeap) int

Purpose

Len int slice.

Parameters

h &IntHeap
height or handle (read-only borrow; caller keeps the original; type &IntHeap)

Returns

int — a value of this type

len_strs

XuAPI
pub fn len_strs(h &StrHeap) int

Purpose

Len strs.

Parameters

h &StrHeap
height or handle (read-only borrow; caller keeps the original; type &StrHeap)

Returns

int — a value of this type

($&StrHeap) init

XuAPI
pub fn (h $&StrHeap) init()

Purpose

Initialize internal state and default parameters.

Parameters

h $&StrHeap
The StrHeap instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&IntHeap) init

XuAPI
pub fn (h $&IntHeap) init()

Purpose

Initialize internal state and default parameters.

Parameters

h $&IntHeap
The IntHeap instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&IntHeap) push

XuAPI
pub fn (h $&IntHeap) push(x int)

Purpose

Execute push on $&IntHeap.

Parameters

h $&IntHeap
The IntHeap instance used by this call (exclusive borrow).
x int
value (int)

Returns

This call does not return a value.

($&IntHeap) pop

XuAPI
pub fn (h $&IntHeap) pop() int

Purpose

Execute pop on $&IntHeap. Throws on failure; handle the error or propagate it to the caller.

Parameters

h $&IntHeap
The IntHeap instance used by this call (exclusive borrow).

Returns

int — a value of this type

($&StrHeap) push

XuAPI
pub fn (h $&StrHeap) push(x string)

Purpose

Execute push on $&StrHeap.

Parameters

h $&StrHeap
The StrHeap instance used by this call (exclusive borrow).
x string
value (string)

Returns

This call does not return a value.

($&StrHeap) pop

XuAPI
pub fn (h $&StrHeap) pop() string

Purpose

Execute pop on $&StrHeap. Throws on failure; handle the error or propagate it to the caller.

Parameters

h $&StrHeap
The StrHeap instance used by this call (exclusive borrow).

Returns

string — result string