xarray.h

Go to the documentation of this file.
00001 /*************************************************************************
00002  * xarray.h: Mutable (dynamically growable) array (header file)
00003  *************************************************************************
00004  * Copyright (C) 2004 Commonwealth Scientific and Industrial Research
00005  *                    Organisation (CSIRO) Australia
00006  * Copyright (C) 2004 the VideoLAN team
00007  *
00008  * $Id$
00009  *
00010  * Authors: Andre Pang <Andre.Pang@csiro.au>
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00025  ************************************************************************/
00026 
00027 #ifndef __XARRAY_H__
00028 #define __XARRAY_H__
00029 
00030 #define XARRAY_DEFAULT_SIZE 69
00031 
00032 /* Error codes */
00033 enum xarray_errors
00034 {
00035     XARRAY_SUCCESS, XARRAY_ENULLPOINTER, XARRAY_ENEGATIVEINDEX,
00036     XARRAY_EINDEXTOOLARGE, XARRAY_ENOMEM, XARRAY_EEMPTYARRAY,
00037     XARRAY_ECOUNTOUTOFBOUNDS
00038 };
00039 
00040 
00041 typedef struct
00042 {
00043     void **array;
00044     int last_valid_element;
00045     unsigned int size;
00046     unsigned int last_error;
00047 }
00048 XArray;
00049 
00050 /* Mutable methods */
00051 int      xarray_AddObject (XArray *xarray, void *object);
00052 int      xarray_InsertObject (XArray *xarray, void *object,
00053                                       unsigned int at_index);
00054 int      xarray_RemoveLastObject (XArray *xarray);
00055 int      xarray_RemoveObject (XArray *xarray, unsigned int at_index);
00056 int      xarray_RemoveObjects (XArray *xarray, unsigned int at_index,
00057                                        int count);
00058 int      xarray_RemoveObjectsAfter (XArray *xarray, unsigned int index);
00059 int      xarray_ReplaceObject (XArray *xarray, unsigned int index,
00060                                        void *new_object);
00061 
00062 /* Immutable methods */
00063 XArray * xarray_New ();
00064 int      xarray_ObjectAtIndex (XArray *xarray, unsigned int index,
00065                                        void **out_object);
00066 int      xarray_Count (XArray *xarray, unsigned int *out_count);
00067 
00068 #endif /* __XARRAY_H__ */
00069 

Generated on Wed Mar 31 08:05:20 2010 for VLC by  doxygen 1.5.6