API
#container/list
Xu 0.8.8 API
import: #container/list
counts: 7 fns, 10 methods, 1 types, 0 consts, 0 ifaces
Doubly linked list; values are owning strings.
struct List
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
pub fn (l &mut List) init()
Purpose
Call `init` on `&mut List`.
Parameters
l &mut List- receiver &mut List (exclusive borrow)
new
Purpose
Construct a new value of this type.
Parameters
none
Returns
List — a value of this type
(&mut List) push_back
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
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
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
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
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
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
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
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
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
Purpose
Return the length.
Parameters
l &List- l (borrowed; caller keeps it; type &List)
Returns
int — a value of this type
front
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
Purpose
back; returns int.
Parameters
l &List- l (borrowed; caller keeps it; type &List)
Returns
int — a value of this type
next
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
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
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