stack.h File Reference

Documentation for Stack Library (CDSL). More...

This graph shows which files directly or indirectly include this file:


Typedefs

typedef struct stack_t stack_t
 represents a stack.

Functions

stack creating and destroying functions:
stack_tstack_new (void)
 creates a stack.
void stack_free (stack_t **)
 destroys a stack.
data handling functions:
void stack_push (stack_t *, void *)
 pushes data into a stack.
void * stack_pop (stack_t *)
 pops data from a stack.
misc. functions:
int stack_empty (const stack_t *)
 inspects if a stack is empty.

Detailed Description

Documentation for Stack Library (CDSL).

Header for Stack Library (CDSL).


Function Documentation

int stack_empty ( const stack_t stk  ) 

inspects if a stack is empty.

stack_empty() inspects if a given stack is empty.

Possible exceptions: assert_exceptfail

Unchecked erros: foreign data structure given for stk

Parameters:
[in] stk stack to inspect
Returns:
whether stack is empty or not
Return values:
1 empty
0 not empty

void stack_free ( stack_t **  stk  ) 

destroys a stack.

stack_free() deallocates all storages for a stack and set the pointer passed through stk to a null pointer. Note that stack_free() does not deallocate any storage for the data in the stack to destroy, which must be done by a user.

Possible exceptions: assert_exceptfail

Unchecked errors: foreign data structure given for stk

Warning:
The storage allocated for data (whose address a stack's node possesses) is never touched; its allocation and deallocation is entirely up to the user.
Parameters:
[in,out] stk pointer to stack to destroy
Returns:
nothing

stack_t* stack_new ( void   ) 

creates a stack.

stack_new() creates a new stack and sets its relevant information to the initial.

Possible exceptions: mem_exceptfail

Unchecked errors: none

Returns:
created stack

void* stack_pop ( stack_t stk  ) 

pops data from a stack.

stack_pop() pops data from a given stack. If the stack is empty, an exception is raised due to the assertion failure, so popping all data without knowing the number of nodes remained in the stack needs to use stack_empty() to decide when to stop.

Possible exceptions: assert_exceptfail

Unchecked errors: foreign data structure given for stk

Parameters:
[in,out] stk stack from which data popped
Returns:
data popped from stack

void stack_push ( stack_t stk,
void *  data 
)

pushes data into a stack.

stack_push() pushes data into the top of a stack. There is no explicit limit on the maximum number of data that can be pushed into a stack.

Possible exceptions: mem_exceptfail, assert_exceptfail

Unchecked errors: foreign data structure given for stk

Parameters:
[in,out] stk stack into which given data pushed
[in] data data to push
Returns:
nothing


Generated on Mon Jan 24 01:13:00 2011 for The Stack Library by  doxygen 1.5.8