group Stacks

Warning!

It must be noted that if you wish to tuck into the structure of the stack, elements are placed within a 'C' array of pointers and the first element is at [1] *not* [0] as you would expect. The stack_ptr variable points to the current head of the stack, for instance if stack_ptr is equal to 1, then [1] has a value in it.

Description

Stacks are another useful data structure. Here is a stright forward implementation.

group contents
Functions
function ferite_create_stack(FeriteScript,int) - Create a stack
function ferite_delete_stack(FeriteScript,FeriteStack) - Delete a stack and free up the memory it uses
function ferite_duplicate_stack(FeriteScript,FeriteStack,void) - Duplicate a stack
function ferite_duplicate_stack_contents(FeriteScript,FeriteStack,void) - Duplicate the contents of a stack
function ferite_stack_pop(FeriteStack) - Pop a value off the top of the stack and return it
function ferite_stack_push(FeriteStack,void) - Push a value onto the stack
function ferite_stack_top(FeriteStack) - Return the top item off the stack without changing the stack's state

Functions

function ferite_create_stack Click to go up to the list
Create a stack
Declaration:
    FeriteStack *ferite_create_stack( FeriteScript *script, int size )
Description:
It is important to note that the stacks contents go from 1 to stack->stack_ptr
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: int size - The initial size of the stack
Returns:
    A new stack structure

function ferite_delete_stack Click to go up to the list
Delete a stack and free up the memory it uses
Declaration:
    void ferite_delete_stack( FeriteScript *script, FeriteStack *stack )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: FeriteStack *stack - The stack to delete

function ferite_duplicate_stack Click to go up to the list
Duplicate a stack
Declaration:
    FeriteStack *ferite_duplicate_stack( FeriteScript *script, FeriteStack *stack, void *(*ddup)( FeriteScript*,void *data,void *data2 ), void *data2 )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: FeriteStack *stack - The stack that should be duplicated
    Parameter #3: void *ddup - The function that gets called to copy the data within the stack
Returns:
    An exact copy of the stacks and it's contents

function ferite_duplicate_stack_contents Click to go up to the list
Duplicate the contents of a stack
Declaration:
    void **ferite_duplicate_stack_contents( FeriteScript *script, FeriteStack *stack, void *(*ddup)( FeriteScript*,void *data,void *data2 ), void *data2 )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: FeriteStack *stack - The stack whose contents should be duplicated
    Parameter #3: void *ddup - The function that gets called to copy the data
Returns:
    An exact copy of the stacks' contents

function ferite_stack_pop Click to go up to the list
Pop a value off the top of the stack and return it
Declaration:
    void *ferite_stack_pop( FeriteStack *stck )
Parameters:
    Parameter #1: FeriteStack *stck - The stack to pop the value off
Returns:
    The popped off value

function ferite_stack_push Click to go up to the list
Push a value onto the stack
Declaration:
    void ferite_stack_push( FeriteStack *stck, void *ptr )
Parameters:
    Parameter #1: FeriteStack *stck - The stack to push the value onto
    Parameter #2: void *ptr - The pointer to push onto the stack

function ferite_stack_top Click to go up to the list
Return the top item off the stack without changing the stack's state
Declaration:
    void *ferite_stack_top( FeriteStack *stck )
Parameters:
    Parameter #1: FeriteStack *stck - The stack to get the item off
Returns:
    The value

Automatically generated at 12:07PM, Wednesday 25 May 2005 by feritedoc.