Introduction | Initialization | Closing | Adding | Deleting | Fetching | Parameters | Advanced | Obscure


Yes, LibDS has a stack implementation as well. This is in keeping with the name and purpose of the library.


A stack is a data structure that supports the last-in first-out processing of data. Data are pushed onto the stack in a particular order. To retrieve data, it is popped off the stack. The invariant here is that the order in which the items come off the stack is exactly the reverse order in which they were pushed onto the stack.

LibDS refers to a stack as STACK.


STACK stkMake(void)

Create a new STACK. Returns NULL on failure.


void stkClose(STACK stack)

Close the stack, releasing all memory it was using. User data is left untouched.

void stkCloseWithFunction(STACK stack,void (*fun)(void*))

Close the stack and call fun on each data in the stack.


int stkPush(STACK stack,void *data)

Pushes this data onto the stack. Returns 0 on success, -1 on failure.


void* stkPop(STACK stack)

Pops the top item from the stack and return it. Returns NULL if stack is empty.


void* stkPeek(STACK stack)

Returns, without removing it, the top item on the stack. Returns NULL if the stack is empty.


int stkSize(STACK stack)

Returns the number of items currently on the stack.

int stkEmpty(STACK stack)

Returns 0 if the stack still has items on it, 1 if it is empty.

Advanced functionality

What exactly did you have in mind?

Obscure functionality

None whatsoever.

Sat Dec 15 18:31:13 EST 2001