dynlist.h File Reference

Definitions of dynlist functions and data elements. More...

#include <stdlib.h>

Include dependency graph for dynlist.h:

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

Go to the source code of this file.

Data Structures

struct  dynlistitem
 Dynlist item struct. More...
struct  dynlist
 Dynlist struct. More...

Defines

#define dynlist(x, y)   dynlist (x)=createlist(sizeof(y))
 Dynlist creation shortcut.

Functions

dynlist createlist (int itemsize)
 Creates a list.
void * newitem (dynlist *list)
 Create new item in list.
void * getitem (dynlist *list, int i)
 Get item pointer.
void eraseitem (dynlist *list, int i)
 Erase item from list.
void clearlist (dynlist *list)
 Clear list from memory.
long getsize (dynlist list)
 Get total size.
long getlen (dynlist list)
 Get number of items.
void * compile (dynlist list)
 Compile list to static array.
void swap (dynlist *list, int i, int j)
 Swap two items in list.
void reverse (dynlist *list)
 Reverse list.
void additem (dynlist *list, void *item, int i)
 Add item to list.
void appenditem (dynlist *list, void *item)
 Append item to list.
void catlists (dynlist *list1, dynlist *list2)
 Join 2 lists.
dynlist splitlist (dynlist *list, int i)
 Split a list.
dynlist decompile (void *data, int itemsize, int num)
 "Decompile" array into dynamic list
void sortlist (dynlist *list, int(*func)(void *, void *))
 Sort the list, using a user-defined function for comparison.
dynlistitemgetdl (dynlist *list, int i)


Detailed Description

Author:
Mephisto

Definition in file dynlist.h.


Define Documentation

#define dynlist ( x,
 )     dynlist (x)=createlist(sizeof(y))

This macro function uses createlist to create a dynlist object<name of the list <type of variable to be managed (eg. int)

Definition at line 31 of file dynlist.h.


Function Documentation

void additem ( dynlist list,
void *  item,
int  i 
)

This function adds *item to *list at index i

Parameters:
list  pointer to list
item  pointer to previously created item
i  index at which to add the item

Definition at line 66 of file dynlist.c.

void appenditem ( dynlist list,
void *  item 
)

This function appends *item to *list

Parameters:
list  pointer to list
item  pointer to previously created item

Definition at line 105 of file dynlist.c.

void catlists ( dynlist list1,
dynlist list2 
)

This function appends *list2 to *list1

Parameters:
list1  pointer to original list
list2  pointer to list to be appended

Definition at line 119 of file dynlist.c.

void clearlist ( dynlist list  ) 

This function clearsthe list *list, and all its items, from memory

Parameters:
list  pointer to list

Definition at line 370 of file dynlist.c.

void* compile ( dynlist  list  ) 

This function attemps to allocate sufficient space to contain list as a static array, and "compile" the dynamic list into it

Parameters:
list  list

Definition at line 426 of file dynlist.c.

dynlist createlist ( int  itemsize  ) 

This function returns a dynlist object for items of size itemsize

Parameters:
itemsize  size of items to be managed

Definition at line 10 of file dynlist.c.

dynlist decompile ( void *  data,
int  itemsize,
int  num 
)

This function reads an array of num items of size itemsize at location data and converts it to a dynamic list

Parameters:
data  the array
itemsize  size of individual items
num  number of items

Definition at line 454 of file dynlist.c.

void eraseitem ( dynlist list,
int  i 
)

This function erases the item at index i from list *list

Parameters:
list  pointer to list
i  index

Definition at line 328 of file dynlist.c.

dynlistitem* getdl ( dynlist list,
int  i 
)

function for internal use

Definition at line 215 of file dynlist.c.

void* getitem ( dynlist list,
int  i 
)

This function returns a pointer to the item at index i in list *list

Parameters:
list  pointer to list
i  index

Definition at line 302 of file dynlist.c.

long getlen ( dynlist  list  ) 

This function returns the total number of items in list

Parameters:
list  list

Definition at line 410 of file dynlist.c.

long getsize ( dynlist  list  ) 

This function returns the total size allocated to accomodate list, and all its items

Parameters:
list  list

Definition at line 394 of file dynlist.c.

void* newitem ( dynlist list  ) 

This function creates a new item in *list

Parameters:
list  pointer to list

Definition at line 27 of file dynlist.c.

void reverse ( dynlist list  ) 

This function reverses all the items in *list

Parameters:
list  pointer to list

Definition at line 173 of file dynlist.c.

void sortlist ( dynlist list,
int(*)(void *, void *)  func 
)

This function sorts the items in *list based on the function implemented by the user at func

Parameters:
list  pointer to the list to be sorted
func  pointer to comparing function

Definition at line 472 of file dynlist.c.

dynlist splitlist ( dynlist list,
int  i 
)

This function splits *list at i and returns a new list containing anything from i

Parameters:
list  pointer to original list
i  index at which to split the list

Definition at line 143 of file dynlist.c.

void swap ( dynlist list,
int  i,
int  j 
)

This function swaps the items at index i and j in-place

Parameters:
list  pointer to list
i  first index(i)
j  second index(j)

Definition at line 195 of file dynlist.c.


Generated on Wed Mar 19 12:08:08 2008 for dynlist by  doxygen 1.5.3