XU XUv0.8.8
中文

API

#container/ring

import: #container/ring

counts: 9 fns, 4 methods, 1 types, 0 consts, 0 ifaces

Ring list; values are owning strings.

struct Ring

XuAPI
pub struct Ring {
    pub val []string
    pub next []int
    pub prev []int
    pub cur int
}

Purpose

Circular list aligned with `container/ring`, specialized to owning strings (no `temp`, no element pointers). a Ring owns a dense circular arena; element handles are indices. Unlink/link rebuild the active cycle (O(n)) — fine for the small rings this package targets. Do(fn) available since (fn values).

Parameters

val []string
value
next []int
field ([]int)
prev []int
field ([]int)
cur int
field (int)

new

XuAPI
pub fn new(n int) Ring

Purpose

Construct a new value of this type.

Parameters

n int
count, length, or limit (int)

Returns

Ring — a value of this type

len

XuAPI
pub fn len(r &Ring) int

Purpose

Return the length.

Parameters

r &Ring
rune (Unicode code point) (borrowed; caller keeps it; type &Ring)

Returns

int — a value of this type

next

XuAPI
pub fn next(r &Ring, e int) int

Purpose

Take the next item, or end according to this type.

Parameters

r &Ring
rune (Unicode code point) (borrowed; caller keeps it; type &Ring)
e int
e (int)

Returns

int — a value of this type

prev

XuAPI
pub fn prev(r &Ring, e int) int

Purpose

prev; returns int.

Parameters

r &Ring
rune (Unicode code point) (borrowed; caller keeps it; type &Ring)
e int
e (int)

Returns

int — a value of this type

move

XuAPI
pub fn move(r &Ring, e int, n int) int

Purpose

move; returns int.

Parameters

r &Ring
rune (Unicode code point) (borrowed; caller keeps it; type &Ring)
e int
e (int)
n int
count, length, or limit (int)

Returns

int — a value of this type

value

XuAPI
pub fn value(r &Ring, e int) string

Purpose

value; returns string.

Parameters

r &Ring
rune (Unicode code point) (borrowed; caller keeps it; type &Ring)
e int
e (int)

Returns

string — result string

(&mut Ring) set_value

XuAPI
pub fn (r &mut Ring) set_value(e int, v string)

Purpose

Method on `&mut Ring`: set value.

Parameters

r &mut Ring
receiver &mut Ring (exclusive borrow)
e int
e (int)
v string
value (string)

cur

XuAPI
pub fn cur(r &Ring) int

Purpose

cur; returns int.

Parameters

r &Ring
rune (Unicode code point) (borrowed; caller keeps it; type &Ring)

Returns

int — a value of this type

(&mut Ring) set_cur

XuAPI
pub fn (r &mut Ring) set_cur(e int)

Purpose

Method on `&mut Ring`: set cur.

Parameters

r &mut Ring
receiver &mut Ring (exclusive borrow)
e int
e (int)

values

XuAPI
pub fn values(r &Ring) []string

Purpose

values; returns []string.

Parameters

r &Ring
rune (Unicode code point) (borrowed; caller keeps it; type &Ring)

Returns

[]string — slice result

do

XuAPI
pub fn do(r &Ring, f fn(string))

Purpose

Do visits each element once, clockwise from cur.

Parameters

r &Ring
rune (Unicode code point) (borrowed; caller keeps it; type &Ring)
f fn(string)
byte callback: argument is 0..255, return whether it matches