1 | /* |
---|
2 | * Copyright (C) 2005,2007 Timothy D. Morgan |
---|
3 | * |
---|
4 | * This program is free software; you can redistribute it and/or modify |
---|
5 | * it under the terms of the GNU General Public License as published by |
---|
6 | * the Free Software Foundation; version 2 of the License. |
---|
7 | * |
---|
8 | * This program is distributed in the hope that it will be useful, |
---|
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | * GNU General Public License for more details. |
---|
12 | * |
---|
13 | * You should have received a copy of the GNU General Public License |
---|
14 | * along with this program; if not, write to the Free Software |
---|
15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
16 | * |
---|
17 | * $Id: void_stack.h 81 2007-01-17 16:47:39Z tim $ |
---|
18 | */ |
---|
19 | |
---|
20 | #include <stdlib.h> |
---|
21 | #include <stdbool.h> |
---|
22 | #include <string.h> |
---|
23 | |
---|
24 | #ifndef _VOID_STACK_H |
---|
25 | #define _VOID_STACK_H |
---|
26 | |
---|
27 | typedef struct _void_stack |
---|
28 | { |
---|
29 | void** elements; |
---|
30 | unsigned short max_size; |
---|
31 | unsigned short top; |
---|
32 | } void_stack; |
---|
33 | |
---|
34 | typedef struct _void_stack_iterator |
---|
35 | { |
---|
36 | void_stack* stack; |
---|
37 | unsigned short cur; |
---|
38 | } void_stack_iterator; |
---|
39 | |
---|
40 | |
---|
41 | /* XXX: need to document these interfaces */ |
---|
42 | void_stack* void_stack_new(unsigned short max_size); |
---|
43 | void_stack* void_stack_copy(const void_stack* v); |
---|
44 | void_stack* void_stack_copy_reverse(const void_stack* v); |
---|
45 | void void_stack_free(void_stack* stack); |
---|
46 | void void_stack_free_deep(void_stack* stack); |
---|
47 | unsigned short void_stack_size(void_stack* stack); |
---|
48 | void* void_stack_pop(void_stack* stack); |
---|
49 | bool void_stack_push(void_stack* stack, void* e); |
---|
50 | const void* void_stack_cur(void_stack* stack); |
---|
51 | void_stack_iterator* void_stack_iterator_new(void_stack* stack); |
---|
52 | void void_stack_iterator_free(void_stack_iterator* iter); |
---|
53 | const void* void_stack_iterator_next(void_stack_iterator* iter); |
---|
54 | |
---|
55 | #endif |
---|