-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstack.h
57 lines (36 loc) · 2.2 KB
/
stack.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (C) 2011-2015 YesLogic Pty. Ltd.
// Released as Open Source (see COPYING.txt for details)
#include "tree.h"
typedef struct element_stack_s element_stack;
struct element_stack_s {
element_node *e;
element_stack *tail;
};
/*if st is empty, return 1, otherwise return 0*/
int open_element_stack_is_empty(element_stack *st);
void open_element_stack_push(element_stack **st, element_node *e);
/*if element_stack is empty, return 0, otherwise pop the top element and return 1 */
int open_element_stack_pop(element_stack **st);
/*returns 1 if e is in st AND is the last element in st, otherwise returns 0.*/
int is_last_element_in_stack(element_stack *st, element_node *e);
/*pop elements up to and including the element named element_name, or to the end of the stack*/
void pop_elements_up_to(element_stack **st, unsigned char *element_name);
/*pop elements up to and including the element e, or to the end of the stack*/
void pop_ele_up_to(element_stack **st, element_node *e);
/*if element_stack is empty, return NULL, otherwise return the top element*/
element_node *open_element_stack_top(element_stack *st);
/*if e is on the stack, return 1, otherwise return 0*/
int is_on_element_stack(element_stack *st, element_node *e);
/*if st is NULL, return NULL, otherwise return a pointer to the previous node.(it could be NULL)*/
element_stack *previous_stack_node(element_stack *st);
/*if st is NULL, return NULL, otherwise return the stack node before e, (it could be NULL)*/
element_stack *stack_node_before_element(element_stack *st, element_node *e);
/*remove element e from the stack, if it is in the stack*/
void remove_element_from_stack(element_stack **st, element_node *e);
/*replace element e with element replacement, if e is in the stack*/
void replace_element_in_stack(element_stack *st, element_node *e, element_node *replacement);
/*insert element e into the stack immediately below element existing_e*/
/*if existing_e in not in stack, then e will not be inserted at all*/
void insert_into_stack_below_element(element_stack **st, element_node *e, element_node *existing_e);
/*free the stack of open elements*/
void free_element_stack(element_stack *st);