forked from yourtion/LearningMasteringAlgorithms-C
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.c
More file actions
40 lines (31 loc) · 1.23 KB
/
stack.c
File metadata and controls
40 lines (31 loc) · 1.23 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
//
// stack.c
// Algorithms - stack
//
// Created by YourtionGuo on 25/04/2017.
// Copyright © 2017 Yourtion. All rights reserved.
//
#include <stdio.h>
#include "list.h"
#include "stack.h"
#pragma mark - Public
/*****************************************************************************
* *
* ------------------------------ stack_push ------------------------------ *
* *
*****************************************************************************/
int stack_push(Stack *stack, const void *data)
{
/// 将数据压入栈
return list_ins_next(stack, NULL, data);
}
/*****************************************************************************
* *
* ------------------------------ stack_pop ------------------------------- *
* *
*****************************************************************************/
int stack_pop(Stack *stack, void **data)
{
/// 弹出栈顶元素
return list_rem_next(stack, NULL, data);
}