Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

xarray.h

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: xarray.h 11664 2005-07-09 06:17:09Z courmisch $
00009  *
00010  * Authors: Andre Pang <[email protected]>
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00025  ************************************************************************/
00026 
00027 #ifndef __XARRAY_H__
00028 #define __XARRAY_H__
00029 
00030 /* define this to 'static' for static linkage */
00031 #define XSTATIC
00032 
00033 #define XARRAY_DEFAULT_SIZE 69
00034 #define xarray_malloc malloc
00035 
00036 /* Error codes */
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 /* Mutable methods */
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 /* Immutable methods */
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 /* __XARRAY_H__ */
00073 

Generated on Tue Dec 20 10:14:28 2005 for vlc-0.8.4a by  doxygen 1.4.2