XU XUv0.8.8
中文

API

#container/list

import: #container/list

counts: 7 fns, 10 methods, 1 types, 0 consts, 0 ifaces

Doubly linked list; values are owning strings.

struct List

XuAPI
pub struct List {
    pub val []string
    pub next []int
    pub prev []int
    pub len int
    pub free int
}

Purpose

Doubly-linked list aligned with `container/list`, specialized to owning strings (no `temp`). Nodes live in parallel arrays; 0 is a circular sentinel. Remove recycles indices via a free list so insert/remove stay O(1) and do not compact.

Parameters

val []string
value
next []int
field ([]int)
prev []int
field ([]int)
len int
field (int)
free int
field (int)

(&mut List) init

XuAPI
pub fn (l &mut List) init()

Purpose

Call `init` on `&mut List`.

Parameters

l &mut List
receiver &mut List (exclusive borrow)

new

XuAPI
pub fn new() List

Purpose

Construct a new value of this type.

Parameters

none

Returns

List — a value of this type

(&mut List) push_back

XuAPI
pub fn (l &mut List) push_back(v string) int

Purpose

Method on `&mut List`: push back.

Parameters

l &mut List
receiver &mut List (exclusive borrow)
v string
value (string)

Returns

int — a value of this type

(&mut List) push_front

XuAPI
pub fn (l &mut List) push_front(v string) int

Purpose

Method on `&mut List`: push front.

Parameters

l &mut List
receiver &mut List (exclusive borrow)
v string
value (string)

Returns

int — a value of this type

(&mut List) insert_after

XuAPI
pub fn (l &mut List) insert_after(e int, v string) int

Purpose

Method on `&mut List`: insert after.

Parameters

l &mut List
receiver &mut List (exclusive borrow)
e int
e (int)
v string
value (string)

Returns

int — a value of this type

(&mut List) insert_before

XuAPI
pub fn (l &mut List) insert_before(e int, v string) int

Purpose

Method on `&mut List`: insert before.

Parameters

l &mut List
receiver &mut List (exclusive borrow)
e int
e (int)
v string
value (string)

Returns

int — a value of this type

(&mut List) remove

XuAPI
pub fn (l &mut List) remove(e int) string

Purpose

Method on `&mut List`: remove.

Parameters

l &mut List
receiver &mut List (exclusive borrow)
e int
e (int)

Returns

string — result string

(&mut List) move_to_front

XuAPI
pub fn (l &mut List) move_to_front(e int)

Purpose

Method on `&mut List`: move to front.

Parameters

l &mut List
receiver &mut List (exclusive borrow)
e int
e (int)

(&mut List) move_to_back

XuAPI
pub fn (l &mut List) move_to_back(e int)

Purpose

Method on `&mut List`: move to back.

Parameters

l &mut List
receiver &mut List (exclusive borrow)
e int
e (int)

(&mut List) move_after

XuAPI
pub fn (l &mut List) move_after(e int, mark int)

Purpose

Method on `&mut List`: move after.

Parameters

l &mut List
receiver &mut List (exclusive borrow)
e int
e (int)
mark int
mark (int)

(&mut List) move_before

XuAPI
pub fn (l &mut List) move_before(e int, mark int)

Purpose

Method on `&mut List`: move before.

Parameters

l &mut List
receiver &mut List (exclusive borrow)
e int
e (int)
mark int
mark (int)

len

XuAPI
pub fn len(l &List) int

Purpose

Return the length.

Parameters

l &List
l (borrowed; caller keeps it; type &List)

Returns

int — a value of this type

front

XuAPI
pub fn front(l &List) int

Purpose

front; returns int.

Parameters

l &List
l (borrowed; caller keeps it; type &List)

Returns

int — a value of this type

back

XuAPI
pub fn back(l &List) int

Purpose

back; returns int.

Parameters

l &List
l (borrowed; caller keeps it; type &List)

Returns

int — a value of this type

next

XuAPI
pub fn next(l &List, e int) int

Purpose

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

Parameters

l &List
l (borrowed; caller keeps it; type &List)
e int
e (int)

Returns

int — a value of this type

prev

XuAPI
pub fn prev(l &List, e int) int

Purpose

prev; returns int.

Parameters

l &List
l (borrowed; caller keeps it; type &List)
e int
e (int)

Returns

int — a value of this type

value

XuAPI
pub fn value(l &List, e int) string

Purpose

value; returns string.

Parameters

l &List
l (borrowed; caller keeps it; type &List)
e int
e (int)

Returns

string — result string