LibRCG  3.1.1
stack.h
Go to the documentation of this file.
1 
11 #ifndef _STACK_H_
12 #define _STACK_H_
13 
14 #include "iterator.h"
15 
19 typedef struct sStackNode
20 {
22  void* value;
24  struct sStackNode *next;
25 }SStackNode;
26 
31 
35 typedef struct sStack
36 {
38  int size;
41 }SStack;
42 
46 typedef SStack* Stack;
47 
48 //##############################################################################
49 
57 Stack newStack(void);
58 
68 void stackDelete(Stack stack);
69 
80 int stackPush(Stack stack,void* value);
81 
99 int stackPop(Stack stack,void** value);
100 
118 int stackTop(Stack stack,void** value);
119 
128 int stackSize(Stack stack);
129 
142 int stackMap(Stack stack,void(*fun)(void*));
143 
156 
157 #endif
void stackDelete(Stack stack)
Deletes a stack.
Definition: stack.c:26
int stackTop(Stack stack, void **value)
Provides the value of the element at the top of a stack.
Definition: stack.c:84
int stackSize(Stack stack)
Returns the size of a stack.
Definition: stack.c:98
int stackPush(Stack stack, void *value)
Inserts an element at the top of the stack.
Definition: stack.c:44
Stack node structure.
Definition: stack.h:19
struct sStackNode * next
Next node.
Definition: stack.h:24
int stackPop(Stack stack, void **value)
Removes an elements from the top of a stack.
Definition: stack.c:62
int stackMap(Stack stack, void(*fun)(void *))
Applies a function to the elements of a stack.
Definition: stack.c:105
Iterator structure.
Definition: iterator.h:17
SStack * Stack
Stack definition.
Definition: stack.h:46
Iterator stackIterator(Stack stack)
Creates an iterator from a stack.
Definition: stack.c:122
Stack newStack(void)
Creates a stack.
Definition: stack.c:13
void * value
Node's value.
Definition: stack.h:22
Stack structure.
Definition: stack.h:35
SStackNode * StackNode
Stack node definition.
Definition: stack.h:30
StackNode top
Top node of this stack.
Definition: stack.h:40
Implementation of an iterator.
int size
Number of values of this stack.
Definition: stack.h:38

LibRCG © 2004-2015   Rui Carlos Gonçalves