Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

epStack.c File Reference

#include <stdio.h>
#include "epDefs.h"
#include "epStack.h"
#include "epList.h"

Include dependency graph for epStack.c:

Include dependency graph

Go to the source code of this file.

Functions

epStack_t* epStack_create (int (*elementDeallocatorFunction)(void *elt))
int epStack_destroy (epStack_t *stack)
int epStack_push (epStack_t *stack, const void *elt)
void* epStack_pop (epStack_t *stack)
int epStack_size (epStack_t *stack)
boolean_t epStack_isEmpty (epStack_t *stack)
int epStack_setElementPrintFunction ( epStack_t *stack, char *(*elementPrintFunction)(void *elt))
int epStack_printIt (epStack_t *stack, char *title)


Detailed Description

Author(s):
Guillaume Bour. U.B.O 2000/2001

Version:
0.1.0
Date:
28/12/2000

Date:
25/11/2001 added title parameter to epStack_printIt() function.

A generic stack. In fact, a stack is a LIFO list, with a unique access to the top element.
A such stack is no size-limited and can stock any type-defined elements

Definition in file epStack.c.


Function Documentation

epStack_t * epStack_create ( int(* elementDeallocatorFunction)(void *elt) )
 

Create & initialize a new stack.

visibility :: public

Remarks:
If no element deallocator function is passed in argument (i.e. NULL), then the default pointer deallocator function is applied.
Parameters:
elementDeallocatorFunction   the function used to deallocate an element

Returns:
the created stack (a pointer) or NULL if an error occurs

Definition at line 37 of file epStack.c.

int epStack_destroy ( epStack_t * stack )
 

Destroy the stack and all the elements contained into.

visibility :: public

Parameters:
stack   the considered stack
Return values:
0   if OK,
-1   else

Definition at line 55 of file epStack.c.

boolean_t epStack_isEmpty ( epStack_t * stack )
 

Return <true> if the stack is empty, <false> else.

visibility :: public

Parameters:
stack   the considered stack
Return values:
<true>   if the stack is empty,
<false>   if not

Definition at line 129 of file epStack.c.

void * epStack_pop ( epStack_t * stack )
 

Return and remove-from the element on the top of the stack.

visibility :: public

Parameters:
stack   the considered stack
Returns:
the element on the top of the stack, or NULL if the stack is empty

Definition at line 93 of file epStack.c.

int epStack_printIt ( epStack_t * stack,
char * title )
 

Print the content of the stack (its parameters and all its elements).

visibility :: public

Warning:
1. some memory leaks may be encountered
Parameters:
stack   the considered stack
title   a title to print ahead
Return values:
0   if OK,
-1   else.

Definition at line 173 of file epStack.c.

int epStack_push ( epStack_t * stack,
const void * elt )
 

Insert a new element on top of the stack.

visibility :: public

Parameters:
stack   the considered stack
elt   the element to insert
Return values:
0   if OK,
-1   else

Definition at line 74 of file epStack.c.

int epStack_setElementPrintFunction ( epStack_t * stack,
char *(* elementPrintFunction)(void *elt) )
 

Initialize the elementPrintFunction for the use of the printIt function.

visibility :: public

Parameters:
stack   the considered stack
elementPrintFunction   the function to use @reval 0 if OK,
Return values:
-1   else.

Definition at line 149 of file epStack.c.

int epStack_size ( epStack_t * stack )
 

Return the size of the stack (the number of its elements).

visibility :: public

Parameters:
stack   the considered stack
Returns:
the size of the stack

Definition at line 111 of file epStack.c.


Generated at Sun Nov 25 14:05:13 2001 for ExtendedPersonnalLibrary by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000