Add function for popping all nodes from the stack
This commit is contained in:
parent
267092940d
commit
2f3e92c9be
3 changed files with 18 additions and 26 deletions
|
|
@ -515,6 +515,15 @@ void ts_stack_clear(Stack *self) {
|
|||
array_push(&self->heads, self->base_node);
|
||||
}
|
||||
|
||||
TreeArray ts_stack_pop_all(Stack *self, int head_index) {
|
||||
StackPopResult pop = ts_stack_pop_count(self, head_index, -1);
|
||||
if (pop.status != StackPopSucceeded)
|
||||
return (TreeArray)array_new();
|
||||
assert(pop.slices.size == 1);
|
||||
assert(pop.slices.contents[0].head_index == head_index);
|
||||
return pop.slices.contents[0].trees;
|
||||
}
|
||||
|
||||
void ts_stack_set_tree_selection_callback(Stack *self, void *payload,
|
||||
TreeSelectionFunction function) {
|
||||
self->tree_selection_payload = payload;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue