Singly-linked list/Element definition: Difference between revisions
Singly-linked list/Element definition (view source)
Revision as of 14:02, 16 April 2018
, 6 years ago→Remove and return first element
Line 1,371:
<lang stata>transmorphic scalar list_pop(struct list scalar a) {
transmorphic scalar x
if (a.head
_error("empty list")
x = (*a.head).value▼
if (a.head == a.tail) {▼
a.head = a.tail = NULL▼
} else {▼
a.head = (*a.head).next▼
return(x)▼
}
}
}</lang>
|