-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgs_stack.h
More file actions
68 lines (49 loc) · 1.09 KB
/
gs_stack.h
File metadata and controls
68 lines (49 loc) · 1.09 KB
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
58
59
60
61
62
63
64
65
66
67
68
/*
* GUILHERME DE NEZ SILVANO MAR/13/2019
*
* BIBLIOTECA PARA IMPLEMENTAÇÃO DE STACKS (PILHAS)
* PARA MANIPULAÇÃO DE VALORES INTEIROS.
*
* PARA USO EM SISTEMAS UNIX.
*/
#ifndef GS_STACK_
#define GS_STACK_
/*
* DISPONÍVEL EM https://github.com/freebsd/freebsd/blob/master/sys/sys/queue.h
*/
#include <sys/queue.h>
/*
*ESTRUTURA DOS NÓS DA PILHA.
*"int num" É NECESSÁRIO PARA O FUNCIONAMENTO DE pop(stack_t).
*/
struct node {
int num;
SLIST_ENTRY(node) next;
} *np;
/*
*DEFINE O TIPO DE VARIÁVEL stack_t.
*/
typedef SLIST_HEAD (head, node) stack_t;
/*
* INSERE UM VALOR INTEIRO NO TOPO DA PILHA.
*/
void push (int n, stack_t * head);
/*
* REMOVE E RETORNA O VALOR INTEIRO DO TOPO DA PILHA.
*/
int pop (stack_t * head);
/*
* IMPRIME OS VALORES CONTIDOS NA PILHA E SUAS POSIÇÕES
* SENDO QUE 0 -> TOPO.
*/
void print_stack (stack_t * head);
/*
* INICIA PILHA COM UM NÓ NULO.
*/
void init_stack (stack_t * head);
/*
* RETORNA UM TIPO int COM O NUMERO DE ELEMENTOS DA PILHA.
* RETORNA -1 CASO A PILHA ESTEJA VAZIA.
*/
int stack_size(stack_t * head);
#endif