home *** CD-ROM | disk | FTP | other *** search
- #ifndef ARRAY_H
- #define ARRAY_H
-
- #include <exec/types.h>
-
- typedef void* VOIDPTR;
- typedef void (*ArrayDtor) (VOIDPTR); /* ptr-to-Destructor function */
-
- struct Array
- {
- VOIDPTR *vec;
- int length; /* # of elements in array */
- int allocsize; /* # of bytes allocated */
- ArrayDtor dtor; /* Destructor */
- };
-
- typedef struct Array Array;
-
- Array *newArray( int length );
- Array *newStringArray( char *s1, ... ); /* must be NULL terminated */
-
- void freeArray( Array *array );
-
- int setLengthOfArray( Array *array, int newlength ); /* returns length */
- void setArrayDestructor( Array *array, ArrayDtor dtor );
-
- int appendToArray( Array *array, const VOIDPTR elt ); /* returns length */
- int deleteFromArray( Array *array, int i ); /* returns length */
- int deleteItemFromArray( Array *array, const VOIDPTR item );
-
- void doToAllInArray( const Array *array, void (*)(VOIDPTR) );
-
- int arrayIndexOfItem( const Array *array, const VOIDPTR *item );
- int appendToArrayIfAbsent( Array *array, const VOIDPTR item );
-
- typedef int (*comparer)( const VOIDPTR *, const VOIDPTR *);
- /*
- // like qsort func. returns _0_ if equal!
- */
-
- int arrayIndexOfItem2( const Array *array, const VOIDPTR *item, comparer func );
- int appendToArrayIfAbsent2( Array *array, const VOIDPTR item, comparer func );
- int arrayIndexOfString( const Array *array, const char *string );
-
- int appendStringToArrayIfAbsent( Array *array, const char *string );
-
- int appendArrayToArray( Array *target, const Array *source );
-
- int appendArrayToArrayIfAbsent( Array *target, const Array *source );
- int appendArrayToArrayIfAbsent2( Array *target, const Array *source, comparer func );
- int appendStringArrayToArrayIfAbsent( Array *target, const Array *source );
-
- #endif
-