00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef __XARRAY_H__
00028 #define __XARRAY_H__
00029
00030
00031 #define XSTATIC
00032
00033 #define XARRAY_DEFAULT_SIZE 69
00034 #define xarray_malloc malloc
00035
00036
00037 enum xarray_errors
00038 {
00039 XARRAY_SUCCESS, XARRAY_ENULLPOINTER, XARRAY_ENEGATIVEINDEX,
00040 XARRAY_EINDEXTOOLARGE, XARRAY_ENOMEM, XARRAY_EEMPTYARRAY,
00041 XARRAY_ECOUNTOUTOFBOUNDS
00042 };
00043
00044
00045 typedef struct
00046 {
00047 void **array;
00048 int last_valid_element;
00049 unsigned int size;
00050 unsigned int last_error;
00051 }
00052 XArray;
00053
00054
00055 XSTATIC int xarray_AddObject (XArray *xarray, void *object);
00056 XSTATIC int xarray_InsertObject (XArray *xarray, void *object,
00057 unsigned int at_index);
00058 XSTATIC int xarray_RemoveLastObject (XArray *xarray);
00059 XSTATIC int xarray_RemoveObject (XArray *xarray, unsigned int at_index);
00060 XSTATIC int xarray_RemoveObjects (XArray *xarray, unsigned int at_index,
00061 int count);
00062 XSTATIC int xarray_RemoveObjectsAfter (XArray *xarray, unsigned int index);
00063 XSTATIC int xarray_ReplaceObject (XArray *xarray, unsigned int index,
00064 void *new_object);
00065
00066
00067 XSTATIC XArray * xarray_New ();
00068 XSTATIC int xarray_ObjectAtIndex (XArray *xarray, unsigned int index,
00069 void **out_object);
00070 XSTATIC int xarray_Count (XArray *xarray, unsigned int *out_count);
00071
00072 #endif
00073