36 lines
672 B
Text
36 lines
672 B
Text
void function list_insert(struct list scalar a, transmorphic scalar x) {
|
|
struct item scalar i
|
|
i.value = x
|
|
if (a.head == NULL) {
|
|
i.next = NULL
|
|
a.head = a.tail = &i
|
|
} else {
|
|
i.next = a.head
|
|
a.head = &i
|
|
}
|
|
}
|
|
|
|
void function list_insert_end(struct list scalar a, transmorphic scalar x) {
|
|
struct item scalar i
|
|
i.value = x
|
|
i.next = NULL
|
|
if (a.head==NULL) {
|
|
a.head = a.tail = &i
|
|
} else {
|
|
(*a.tail).next = &i
|
|
a.tail = &i
|
|
}
|
|
}
|
|
|
|
void function list_insert_after(struct list scalar a,
|
|
pointer(struct item scalar) scalar p,
|
|
transmorphic scalar x) {
|
|
|
|
struct item scalar i
|
|
i.value = x
|
|
i.next = (*p).next
|
|
(*p).next = &i
|
|
if (a.tail == p) {
|
|
a.tail = &i
|
|
}
|
|
}
|