home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / gui / precog2_1.lha / Precognition2_1 / src / src.lha / Precognition / array.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-20  |  1.8 KB  |  54 lines

  1. #ifndef ARRAY_H
  2. #define ARRAY_H
  3.  
  4. #include <exec/types.h>
  5.  
  6. typedef void* VOIDPTR;
  7. typedef void (*ArrayDtor) (VOIDPTR); /* ptr-to-Destructor function */
  8.  
  9. struct Array
  10. {
  11.    VOIDPTR  *vec;
  12.    int       length;          /* # of elements in array */
  13.    int       allocsize;       /* # of bytes allocated */
  14.    ArrayDtor dtor;            /* Destructor */
  15. };
  16.  
  17. typedef struct Array Array;
  18.  
  19. Array *newArray( int length );
  20. Array *newStringArray( char *s1, ... ); /* must be NULL terminated */
  21.  
  22. void   freeArray( Array *array );
  23.  
  24. int    setLengthOfArray( Array *array, int newlength ); /* returns length */
  25. void   setArrayDestructor( Array *array, ArrayDtor dtor );
  26.  
  27. int    appendToArray( Array *array, const VOIDPTR elt );      /* returns length */
  28. int    deleteFromArray( Array *array, int i );          /* returns length */
  29. int    deleteItemFromArray( Array *array, const VOIDPTR item );
  30.  
  31. void   doToAllInArray( const Array *array, void (*)(VOIDPTR) );
  32.  
  33. int    arrayIndexOfItem( const Array *array, const VOIDPTR *item );
  34. int    appendToArrayIfAbsent( Array *array, const VOIDPTR item );
  35.  
  36. typedef int (*comparer)( const VOIDPTR *, const VOIDPTR *);
  37.    /*
  38.    // like qsort func.  returns _0_ if equal!
  39.    */
  40.  
  41. int arrayIndexOfItem2( const Array *array, const VOIDPTR *item, comparer func );
  42. int appendToArrayIfAbsent2( Array *array, const VOIDPTR item, comparer func );
  43. int arrayIndexOfString( const Array *array, const char *string );
  44.  
  45. int appendStringToArrayIfAbsent( Array *array, const char *string );
  46.  
  47. int appendArrayToArray( Array *target, const Array *source );
  48.  
  49. int appendArrayToArrayIfAbsent( Array *target, const Array *source );
  50. int appendArrayToArrayIfAbsent2( Array *target, const Array *source, comparer func );
  51. int appendStringArrayToArrayIfAbsent( Array *target, const Array *source );
  52.  
  53. #endif
  54.