Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

nix-common/stack.c File Reference

This provides the stack functions for a unix/linux box. More...

#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <assert.h>
#include <appconfig.h>
#include <stack.h>

Go to the source code of this file.

Data Structures

struct  tag_dsObj
 the data structure for the stack object More...


Typedefs

typedef tag_dsObj dsObj
 the data structure for the stack object


Functions

void StackResize (dsObj *sp, Int32 newSize)
 resize the stack based on the current size

dsObjStackNew (void)
 Create a new stack.

void StackDelete (dsObj *sp)
 delete the stack object

void StackPush (dsObj *sp, Int32 value)
 push an item onto the stack

Int32 StackPop (dsObj *sp)
 pop the first item from the stack

Int8 StackIsEmpty (dsObj *sp)
 check is the stack empty

void StackDoEmpty (dsObj *sp)
 empty the stack

int StackNElements (dsObj *sp)
 get the number of elements on the stack

Int32 ListGet (dsObj *sp, Int32 index)
 get the specific item from the list

void ListSet (dsObj *sp, Int32 index, Int32 element)
 set the value at a certain index into the list to the value

void ListInsert (dsObj *sp, Int32 index, Int32 element)
 insert an item into the list at a certain location

Int32 ListRemove (dsObj *ds, Int32 index)
 remove an item from the list


Detailed Description

This provides the stack functions for a unix/linux box.

Part of the pocketcity application.

It's almost identical to the palm one except it uses malloc/realloc normally. realloc on palm has problems (fragmented heap)

Definition in file stack.c.


Function Documentation

Int32 ListGet dsObj   obj,
Int32    index
 

get the specific item from the list

Parameters:
obj  the list
index  the index into the list to get
Returns:
the value or -1 if not found

Definition at line 103 of file stack.c.

References tag_dsObj::bp, Int32, and tag_dsObj::sp.

void ListInsert dsObj   obj,
Int32    index,
Int32    value
 

insert an item into the list at a certain location

It is inserted at the location shuffling the old item down one on the list.

Parameters:
obj  the list object
index  the index into the list
value  the new value

Definition at line 118 of file stack.c.

References tag_dsObj::bp, Int32, tag_dsObj::sp, and StackPush().

Int32 ListRemove dsObj   obj,
Int32    index
 

remove an item from the list

Parameters:
obj  the list object
index  the index from which to remove the item
Returns:
the value that was stored there

Definition at line 131 of file stack.c.

References tag_dsObj::bp, Int32, tag_dsObj::sp, and StackPop().

void ListSet dsObj   obj,
Int32    index,
Int32    value
 

set the value at a certain index into the list to the value

Parameters:
obj  the list
index  the index into the list
value  the value of that point

Definition at line 111 of file stack.c.

References tag_dsObj::bp, Int32, and tag_dsObj::sp.

void StackDelete dsObj   obj
 

delete the stack object

Parameters:
obj  the object to delete

Definition at line 56 of file stack.c.

References tag_dsObj::bp.

Referenced by DoDistribute().

void StackDoEmpty dsObj   obj
 

empty the stack

Parameters:
obj  the stack to empty

Definition at line 90 of file stack.c.

References tag_dsObj::bp, and tag_dsObj::sp.

Referenced by DoDistribute().

Int8 StackIsEmpty dsObj   obj
 

check is the stack empty

Parameters:
obj  the stack
Returns:
true if the stack is empty, false otherwise

Definition at line 82 of file stack.c.

References tag_dsObj::bp, and tag_dsObj::sp.

Referenced by DistributeUnvisited(), and SupplyIfPlant().

int StackNElements dsObj   obj
 

get the number of elements on the stack

Parameters:
obj  the stack
Returns:
the number of objects on the stack

Definition at line 97 of file stack.c.

References tag_dsObj::bp, and tag_dsObj::sp.

dsObj* StackNew void   
 

Create a new stack.

preallocates 128 elements to the stack

Definition at line 49 of file stack.c.

Referenced by DoDistribute().

Int32 StackPop dsObj   obj
 

pop the first item from the stack

Parameters:
obj  the stack object
Returns:
the top item from the stack

Definition at line 70 of file stack.c.

References tag_dsObj::bp, and tag_dsObj::sp.

Referenced by DistributeUnvisited(), ListRemove(), and SupplyIfPlant().

void StackPush dsObj   obj,
Int32    value
 

push an item onto the stack

Parameters:
obj  the stack
value  the value to push

Definition at line 63 of file stack.c.

References Int32, tag_dsObj::se, tag_dsObj::sl, tag_dsObj::sp, and StackResize().

Referenced by AddNeighbors(), DistributeUnvisited(), and ListInsert().

void StackResize dsObj   sp,
Int32    newSize
[static]
 

resize the stack based on the current size

Parameters:
sp  the stack object
newSize  the new size of the stack

Definition at line 39 of file stack.c.

References tag_dsObj::bp, Int32, tag_dsObj::se, tag_dsObj::sl, and tag_dsObj::sp.

Referenced by StackPop(), and StackPush().


Generated on Mon Aug 30 19:44:18 2004 for pocketcity by doxygen1.2.18