TaPAS  0.2
ccl-stack.h
Go to the documentation of this file.
1 /*
2  * ccl-stack.h -- A generic stack
3  *
4  * This file is a part of the C Common Library (CCL) project.
5  *
6  * Copyright (C) 2010 CNRS UMR 5800 & Université Bordeaux I (see AUTHORS file).
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the AltaRica Public License that comes with this
10  * package.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  */
16 
21 #ifndef __CCL_STACK_H__
22 # define __CCL_STACK_H__
23 
24 # include <ccl/ccl-common.h>
25 
26 BEGIN_C_DECLS
27 
31 typedef struct ccl_stack_st ccl_stack;
32 
37 extern ccl_stack *
38 ccl_stack_create (void);
39 
49 extern void
51 
58 extern int
59 ccl_stack_get_size (const ccl_stack *s);
60 
67 # define ccl_stack_is_empty(_s) (ccl_stack_get_size (_s) == 0)
68 
79 extern void *
81 
92 extern void
93 ccl_stack_push (ccl_stack *s, void *obj);
94 
95 /*
96  * \brief Removes and returns the object at the top of the stack \a s
97  *
98  * The function removes the cell at the top of the non-empty stack \a s and
99  * returns the object stored into this cell.
100  *
101  * \param s the stack
102  * \pre ! ccl_stack_is_empty(s)
103  * \return the object contained in the cell on the top of the stack \a s
104  */
105 extern void *
106 ccl_stack_pop (ccl_stack *s);
107 
108 END_C_DECLS
109 
110 #endif /* ! __CCL_STACK_H__ */
struct ccl_stack_st ccl_stack
Abstract type of a stack.
Definition: ccl-stack.h:31
void ccl_stack_push(ccl_stack *s, void *obj)
Put the object obj on the stack s.
int ccl_stack_get_size(const ccl_stack *s)
Returns the number of elements on the stack s.
Some useful and common macros.
void ccl_stack_delete(ccl_stack *s)
Deletion of the stack s.
void * ccl_stack_get_top(ccl_stack *s)
Returns the object at the top of the stack.
ccl_stack * ccl_stack_create(void)
Creates a new empty stack.