Salad  1.0.15
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
stack.h
Go to the documentation of this file.
1 /*
2  * Salad - An assortment of useful C stuff
3  * Copyright (C) 2016 Lloyd Dilley
4  * http://www.dilley.me/
5  *
6  * This file is part of Salad.
7  *
8  * Salad is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version
11  * 3 of the License, or (at your option) any later version.
12  *
13  * Salad is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with Salad. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
24 #ifndef STACK_H
25 #define STACK_H
26 
27 #include "salad/list.h"
28 #include "salad/types.h"
29 #include "salad/vector.h"
30 
43 
45 typedef struct sld_stack
46 {
49  struct sld_list *list;
50  struct sld_vector *vector;
51 } sld_stack;
52 
65 SLD_SSINT sld_stack_init(struct sld_stack *stack, sld_stack_type stack_type);
66 
77 SLD_UINT sld_stack_size(struct sld_stack *stack);
78 
90 SLD_SSINT sld_stack_push(struct sld_stack *stack, void *object);
91 
102 void *sld_stack_pop(struct sld_stack *stack);
103 
114 void *sld_stack_peek(struct sld_stack *stack);
115 
125 void sld_stack_free(struct sld_stack *stack);
126 
129 #endif /* STACK_H */
Definition: stack.h:45
void * sld_stack_peek(struct sld_stack *stack)
Returns the object at the top of a sld_stack.
Definition: stack.c:117
sld_stack_type
Definition: stack.h:42
signed short int SLD_SSINT
Definition: types.h:47
Definition: list.h:44
SLD_UINT size
Definition: stack.h:48
Definition: vector.h:42
struct sld_vector * vector
Definition: stack.h:50
SLD_SSINT sld_stack_init(struct sld_stack *stack, sld_stack_type stack_type)
Initializes a sld_stack.
Definition: stack.c:33
unsigned int SLD_UINT
Definition: types.h:56
Definition: stack.h:42
SLD_SSINT sld_stack_push(struct sld_stack *stack, void *object)
Adds an object to the top of a sld_stack.
Definition: stack.c:85
struct sld_stack sld_stack
void * sld_stack_pop(struct sld_stack *stack)
Returns and removes the object at the top of a sld_stack.
Definition: stack.c:101
SLD_UINT sld_stack_size(struct sld_stack *stack)
Returns the size of a sld_stack.
Definition: stack.c:80
void sld_stack_free(struct sld_stack *stack)
Frees any memory allocated for an initialized sld_stack.
Definition: stack.c:130
struct sld_list * list
Definition: stack.h:49
sld_stack_type stack_type
Definition: stack.h:47
Definition: stack.h:42