-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack.h
41 lines (27 loc) · 1.52 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
/*****************************************************************************
* *
* ------------------------------- stack.h -------------------------------- *
* *
*****************************************************************************/
#ifndef STACK_H
#define STACK_H
#include <stdlib.h>
#include "list.h"
/*****************************************************************************
* *
* Implement stacks as linked lists. *
* *
*****************************************************************************/
typedef List Stack;
/*****************************************************************************
* *
* --------------------------- Public Interface --------------------------- *
* *
*****************************************************************************/
#define stack_init list_init
#define stack_destroy list_destroy
int stack_push(Stack *stack, const void *data);
int stack_pop(Stack *stack, void **data);
#define stack_peek(stack) ((stack)->head == NULL ? NULL : (stack)->head->data)
#define stack_size list_size
#endif